/* Inbox compact layout — load after workspace-redesign.css.
   Presentation only: same colors, fonts, icons, forms and handlers.
   Spacing scale: 4 / 8 / 12 / 16. Secondary metadata: 12px everywhere (matches the existing !important meta rule). */
:root {
  --ic-meta: var(--type-meta-size);
  --ic-control: var(--control-md);
  --ic-input: var(--input-lg); /* composer row: matches the existing calc(var(--space-1) * 12) minimum input height checked by the browser tests */
  --ic-nav: var(--nav-rail);
  --ic-queue: calc(var(--space-1) * 75);
  --ic-context: calc(var(--space-1) * 80);
  --ic-brief-bg: var(--brand-50);
}

@media (min-width: 761px) {
  body:has(.shell-inbox) .hub-top { min-height: var(--input-lg); height: var(--input-lg); padding-block: var(--space-1); }
  body:has(.shell-inbox) .hub-top .care-brand { max-height: var(--control-lg); }
  /* ---------- 1. Frame: viewport height, one scroll per column ---------- */
  body:has(.hub-body) {
    height: 100dvh;
    overflow: hidden;
  }
  .hub-body {
    grid-template-columns: var(--ic-nav) minmax(0, 1fr);
  }
  .hub-body .unified-layout.shell-inbox {
    grid-template-columns: var(--ic-queue) minmax(0, 1fr) var(--ic-context);
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  /* ---------- 2. Side navigation: icon above one-line label ---------- */
  .hub-body .shell-nav {
    padding: calc(var(--space-1) * 2) var(--space-1);
    gap: var(--space-1);
    overflow-x: hidden;
  }
  .hub-body .shell-nav a {
    display: block;
    flex: none;
    height: calc(var(--space-1) * 15);
    min-height: calc(var(--space-1) * 15);
    padding: calc(var(--space-1) * 2.5) calc(var(--space-1) * 0.5) 0;
    font-size: var(--type-meta-size);
    line-height: calc(var(--space-1) * 4);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .hub-body .shell-nav .nav-symbol {
    display: block;
    width: calc(var(--space-1) * 5.5);
    height: calc(var(--space-1) * 5.5);
    margin: 0 auto calc(var(--space-1) * 1.5);
    font-size: var(--type-page-title-size);
    line-height: 1;
  }
  .hub-body .shell-nav .nav-symbol svg {
    width: calc(var(--space-1) * 5.5);
    height: calc(var(--space-1) * 5.5);
  }

  /* ---------- 3. Inbox queue ---------- */
  .shell-inbox .inbox-queue {
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
  }
  .shell-inbox .queue-title {
    display: flex;
    align-items: center;
    gap: calc(var(--space-1) * 2);
    min-height: 0;
    padding: calc(var(--space-1) * 3) calc(var(--space-1) * 3) 0;
    padding-inline-end: calc(var(--space-1) * 14); /* room for the + button */
  }
  .shell-inbox .queue-title h1 {
    margin: 0;
    font-size: var(--type-section-title-size);
    line-height: calc(var(--space-1) * 7);
  }
  .shell-inbox .workspace-update-status {
    margin: 0;
    padding: 0 calc(var(--space-1) * 3) calc(var(--space-1) * 2);
    min-height: 0;
    font-size: var(--ic-meta);
    line-height: calc(var(--space-1) * 4);
    color: var(--ws-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* When an update fails the status line carries a "retry" button: let it show and receive clicks. */
  .shell-inbox .workspace-update-status:has(button) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) calc(var(--space-1) * 2);
    white-space: normal;
    overflow: visible;
  }
  .shell-inbox .workspace-update-status button {
    height: calc(var(--space-1) * 6);
    min-height: calc(var(--space-1) * 6);
    margin: 0;
    padding: 0 calc(var(--space-1) * 2);
    font-size: var(--ic-meta);
  }
  /* New lead: icon button beside the title (same control, same handler). */
  .shell-inbox .queue-tools {
    position: absolute;
    top: calc(var(--space-1) * 2.5);
    inset-inline-end: calc(var(--space-1) * 3);
    padding: 0;
    margin: 0;
  }
  .shell-inbox #new-lead {
    display: grid;
    place-items: center;
    width: var(--ic-control);
    height: var(--ic-control);
    min-height: var(--ic-control);
    padding: 0;
    margin: 0;
    font-size: 0;
    border-radius: var(--hub-field-radius);
  }
  .shell-inbox #new-lead::before {
    content: '+';
    font-size: var(--type-page-title-size);
    line-height: 1;
  }
  /* Counters as one row of chips. */
  .shell-inbox .saved-views {
    display: flex;
    gap: var(--space-1);
    margin: 0;
    padding: 0 calc(var(--space-1) * 3) calc(var(--space-1) * 2);
  }
  .shell-inbox .saved-views button {
    flex: 1 1 auto;
    min-width: 0;
    height: calc(var(--space-1) * 7);
    min-height: calc(var(--space-1) * 7);
    padding: 0 calc(var(--space-1) * 2);
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    font-size: var(--ic-meta);
    border-radius: var(--hub-field-radius);
    white-space: nowrap;
  }
  .shell-inbox .saved-views button span {
    font-size: var(--ic-meta);
    font-weight: 600;
  }
  /* Company + channel + "more filters" in one row. */
  .shell-inbox .queue-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: var(--space-1);
    padding: 0 calc(var(--space-1) * 3) calc(var(--space-1) * 2);
    position: relative;
  }
  .shell-inbox .queue-filters > label {
    display: block;
    min-width: 0;
    margin: 0;
    font-size: 0; /* visible label hidden; it still names the select */
  }
  .shell-inbox .queue-filters > label select {
    width: 100%;
    height: var(--ic-control);
    min-height: var(--ic-control);
    margin: 0;
    padding: 0 calc(var(--space-1) * 2);
    font-size: var(--ic-meta);
  }
  .shell-inbox .queue-filters .extra-filters {
    grid-column: auto;
    margin: 0;
    padding: 0;
    min-width: 0;
    border: 0;
    background: none;
  }
  .shell-inbox .extra-filters > summary {
    display: flex;
    align-items: center;
    height: var(--ic-control);
    padding: 0 calc(var(--space-1) * 2);
    font-size: var(--ic-meta);
    white-space: nowrap;
    border: calc(var(--space-1) * 0.25) solid var(--ws-line);
    border-radius: var(--hub-field-radius);
    background: var(--surface);
    cursor: pointer;
  }
  .shell-inbox .extra-filters[open] > summary {
    color: var(--ws-brand);
    border-color: var(--ws-brand);
  }
  /* Open filters drop over the list instead of pushing it down. */
  .shell-inbox .queue-filters .extra-filters[open] {
    display: block;
  }
  .shell-inbox .extra-filters[open]::details-content {
    position: absolute;
    top: calc(100% - var(--space-1));
    inset-inline: calc(var(--space-1) * 3);
    z-index: 30;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: calc(var(--space-1) * 2);
    padding: calc(var(--space-1) * 3);
    background: var(--surface);
    border: calc(var(--space-1) * 0.25) solid var(--ws-line);
    border-radius: var(--hub-radius);
    box-shadow: var(--shadow-popover);
  }
  .shell-inbox .extra-filters label {
    font-size: var(--ic-meta);
    margin: 0;
  }
  /* The list is the only scroll in this column. */
  .shell-inbox .queue-rows {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    border-top: calc(var(--space-1) * 0.25) solid var(--ws-line);
  }
  .shell-inbox .queue-item {
    margin: 0;
  }
  /* Row: name + channel | time / preview / company | owner */
  .shell-inbox .queue-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: calc(var(--space-1) * 2);
    row-gap: calc(var(--space-1) * 0.5);
    width: 100%;
    height: auto;
    min-height: 0; /* was calc(var(--space-1) * 28) */
    margin: 0;
    padding: calc(var(--space-1) * 2) calc(var(--space-1) * 3);
    text-align: start;
    border: 0;
    border-bottom: calc(var(--space-1) * 0.25) solid var(--ws-line);
    border-radius: 0;
  }
  .shell-inbox .queue-row > * {
    grid-column: 1 / -1;
    min-width: 0;
  }
  .shell-inbox .queue-row-heading {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: calc(var(--space-1) * 1.5);
    margin: 0;
  }
  .shell-inbox .queue-row-heading strong {
    font-size: var(--type-body-size);
    line-height: calc(var(--space-1) * 5);
  }
  .shell-inbox .queue-channel {
    flex: none;
    font-size: var(--ic-meta);
    line-height: calc(var(--space-1) * 4);
    color: var(--ws-muted);
  }
  .shell-inbox .queue-row-footer {
    display: contents;
  }
  .shell-inbox .queue-row .queue-time {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    font-size: var(--ic-meta);
    line-height: calc(var(--space-1) * 5);
    white-space: nowrap;
  }
  .shell-inbox .queue-row .queue-preview {
    grid-row: 2;
    display: block; /* was a 2-line clamp */
    -webkit-line-clamp: none;
    height: auto; /* was fixed calc(var(--space-1) * 10.5) */
    min-height: 0;
    margin: 0;
    font-size: var(--type-ui-size);
    line-height: calc(var(--space-1) * 5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .shell-inbox .queue-row .queue-company,
  .shell-inbox .queue-row .queue-owner {
    grid-row: 3;
    margin: 0;
    font-size: var(--ic-meta);
    line-height: calc(var(--space-1) * 4);
    color: var(--ws-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .shell-inbox .queue-row .queue-company {
    grid-column: 1;
  }
  /* Overdue marker sits at the end of the preview line instead of adding a 4th line. */
  .shell-inbox .queue-row .queue-overdue {
    grid-row: 2;
    grid-column: 2;
    justify-self: end;
    margin: 0;
    font-size: var(--type-meta-size);
    line-height: calc(var(--space-1) * 5);
  }
  .shell-inbox .queue-row:has(.queue-overdue) .queue-preview {
    grid-column: 1;
  }
  .shell-inbox .queue-row .queue-owner {
    grid-column: 2;
    max-width: calc(var(--space-1) * 24);
  }

  /* ---------- 4. Conversation column ---------- */
  /* Header row: name | scope (company › branch › channel) | stage + owner | actions
     Row 2: next step (one line, expandable) | context link
     Row 3: tabs.  Row 4+: warnings, then the active pane (only flexible row). */
  .shell-inbox .inbox-main {
    display: grid;
    grid-template-columns: minmax(calc(var(--space-1) * 24), max-content) minmax(0, 1fr) auto auto;
    grid-template-rows: auto auto auto auto auto auto minmax(0, 1fr);
    column-gap: calc(var(--space-1) * 3);
    overflow: hidden;
  }
  .shell-inbox .inbox-main::before,
  .shell-inbox .inbox-main::after {
    content: '';
    grid-column: 1 / -1;
    z-index: 0;
  }
  .shell-inbox .inbox-main::before {
    grid-row: 1;
    background: var(--surface);
    border-bottom: calc(var(--space-1) * 0.25) solid var(--ws-line);
  }
  .shell-inbox .inbox-main::after {
    grid-row: 2;
    background: var(--ic-brief-bg);
    border-bottom: calc(var(--space-1) * 0.25) solid var(--ws-line);
  }
  .shell-inbox .inbox-main:not(:has(.workspace-brief))::after {
    display: none;
  }
  .shell-inbox .conversation-heading,
  .shell-inbox .workspace-brief {
    display: contents;
  }
  .shell-inbox .inbox-main > *,
  .shell-inbox .conversation-heading > *,
  .shell-inbox .workspace-brief > * {
    position: relative;
    z-index: 1;
    min-width: 0;
  }
  .shell-inbox #back-inbox {
    grid-row: 1;
  }
  .shell-inbox .conversation-heading .customer-name {
    grid-row: 1;
    grid-column: 1;
    align-self: center;
    margin-inline-start: calc(var(--space-1) * 4);
    padding-block: calc(var(--space-1) * 2);
  }
  .shell-inbox .conversation-heading h2 {
    font-size: var(--type-section-title-size);
    line-height: calc(var(--space-1) * 6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .shell-inbox .conversation-scope {
    grid-row: 1;
    grid-column: 2;
    align-self: center;
    padding: 0;
    border: 0;
    background: none;
    font-size: var(--ic-meta);
    color: var(--ws-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .shell-inbox .conversation-scope small {
    margin-inline-start: calc(var(--space-1) * 2);
    font-size: var(--ic-meta);
  }
  .shell-inbox .workspace-brief-stage {
    grid-row: 1;
    grid-column: 3;
    align-self: center;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: calc(var(--space-1) * 2);
    white-space: nowrap;
  }
  .shell-inbox .workspace-brief-stage .tag {
    padding: calc(var(--space-1) * 0.5) calc(var(--space-1) * 1.5);
    font-size: var(--ic-meta);
    line-height: calc(var(--space-1) * 4);
  }
  .shell-inbox .workspace-brief-stage small {
    font-size: var(--ic-meta);
  }
  .shell-inbox .conversation-heading .actions {
    grid-row: 1;
    grid-column: 4;
    align-self: center;
    display: flex;
    gap: var(--space-1);
    margin-inline-end: calc(var(--space-1) * 4);
  }
  .shell-inbox .conversation-heading .actions > button,
  .shell-inbox .conversation-heading .actions > details > summary {
    height: var(--ic-control);
    min-height: var(--ic-control);
    padding: 0 calc(var(--space-1) * 2.5);
    font-size: var(--type-ui-size);
    display: inline-flex;
    align-items: center;
    gap: calc(var(--space-1) * 1.5);
    white-space: nowrap;
  }
  /* Next step: one line; the existing "التفاصيل" toggle expands it. */
  .shell-inbox .workspace-brief-next {
    grid-row: 2;
    grid-column: 1 / 4;
    display: flex;
    align-items: baseline;
    gap: calc(var(--space-1) * 2);
    min-width: 0;
    margin-inline-start: calc(var(--space-1) * 4);
    padding-block: calc(var(--space-1) * 1.5);
  }
  .shell-inbox .workspace-brief-next small {
    flex: none;
    font-size: var(--ic-meta);
    color: var(--ws-muted);
  }
  .shell-inbox .workspace-brief-next p {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: var(--type-ui-size);
    line-height: calc(var(--space-1) * 5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .shell-inbox .workspace-brief[data-expanded='true'] .workspace-brief-next p {
    white-space: normal;
  }
  .shell-inbox .workspace-brief [data-brief-toggle] {
    grid-row: 2;
    grid-column: 4; /* shares the actions column with the context link */
    justify-self: start;
    align-self: center;
    display: inline-flex;
    height: calc(var(--space-1) * 6);
    min-height: calc(var(--space-1) * 6);
    padding: 0 calc(var(--space-1) * 2);
    margin: 0;
    font-size: var(--ic-meta);
    border: 0;
    background: none;
    color: var(--ws-brand);
  }
  .shell-inbox .workspace-brief-link {
    grid-row: 2;
    grid-column: 4;
    justify-self: end;
    align-self: center;
    height: calc(var(--space-1) * 6.5);
    min-height: calc(var(--space-1) * 6.5);
    padding: 0 calc(var(--space-1) * 2.5);
    margin: 0;
    margin-inline-end: calc(var(--space-1) * 4);
    font-size: var(--ic-meta);
  }
  /* Tabs right under the header. */
  .shell-inbox .customer-tabs {
    grid-row: 3;
    grid-column: 1 / -1;
    display: flex;
    gap: var(--space-1);
    padding: var(--space-1) calc(var(--space-1) * 4);
    margin: 0;
    background: var(--surface);
    border-bottom: calc(var(--space-1) * 0.25) solid var(--ws-line);
  }
  .shell-inbox .customer-tabs button {
    height: calc(var(--space-1) * 7);
    min-height: calc(var(--space-1) * 7);
    padding: 0 calc(var(--space-1) * 3);
    font-size: var(--type-ui-size);
  }
  .shell-inbox .inbox-main > .presence-warning {
    grid-row: 4;
    grid-column: 1 / -1;
  }
  .shell-inbox .inbox-main > .presence-warning:empty {
    display: none;
  }
  .shell-inbox .inbox-main > .identity-guard {
    grid-row: 5;
    grid-column: 1 / -1;
  }
  .shell-inbox .inbox-main > .channel-switch {
    grid-row: 6;
    grid-column: 1 / -1;
    display: flex;
    gap: var(--space-1);
    margin: 0;
    padding: var(--space-1) calc(var(--space-1) * 4);
    background: var(--surface);
    border-bottom: calc(var(--space-1) * 0.25) solid var(--ws-line);
  }
  .shell-inbox .inbox-main > .channel-switch button {
    height: calc(var(--space-1) * 7);
    min-height: calc(var(--space-1) * 7);
    margin: 0;
    padding: 0 calc(var(--space-1) * 3);
    font-size: var(--type-ui-size);
  }
  .shell-inbox .inbox-main > .main-pane,
  .shell-inbox .inbox-main > .conversation-loading {
    grid-row: 7;
    grid-column: 1 / -1;
    min-height: 0;
  }
  .shell-inbox .inbox-main > .main-pane:not(.pane-chat) {
    overflow-y: auto;
  }

  /* Messages: the only flexible, scrolling area. */
  .shell-inbox .pane-chat {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .shell-inbox .conversation-scroll {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
  }
  .shell-inbox .contact-timeline {
    padding: calc(var(--space-1) * 3) calc(var(--space-1) * 4);
  }
  .shell-inbox .timeline-day {
    margin: var(--space-1) 0 calc(var(--space-1) * 2);
  }
  .shell-inbox .timeline-event {
    position: relative;
    padding: calc(var(--space-1) * 1.5) calc(var(--space-1) * 3);
    margin: 0 0 calc(var(--space-1) * 2);
  }
  .shell-inbox .timeline-event.message-continuation {
    margin-top: calc(var(--space-1) * -1);
  }
  .shell-inbox .message-heading {
    display: flex;
    align-items: center;
    gap: calc(var(--space-1) * 2);
    min-height: 0;
    margin: 0;
    font-size: var(--ic-meta);
    line-height: calc(var(--space-1) * 4.5);
  }
  .shell-inbox .message-heading .tag {
    padding: 0 calc(var(--space-1) * 1.5);
    font-size: var(--ic-meta);
    line-height: calc(var(--space-1) * 4.5);
  }
  .shell-inbox .timeline-event p.message-text {
    margin: calc(var(--space-1) * 0.5) 0 0;
    line-height: 1.55;
  }
  /* Message source details: moved into the gutter beside the bubble,
     shown on hover / keyboard focus, so it no longer adds a line per message. */
  .shell-inbox .timeline-event:not(.internal, .email-event) > .message-evidence {
    position: absolute;
    top: calc(var(--space-1) * 1.5);
    width: max-content;
    max-width: calc(var(--space-1) * 65);
    margin: 0;
    font-size: var(--ic-meta);
    opacity: 0;
    transition: opacity var(--hub-motion);
  }
  .shell-inbox .timeline-event.inbound:not(.internal, .email-event) > .message-evidence {
    inset-inline-end: calc(100% + calc(var(--space-1) * 2));
  }
  .shell-inbox .timeline-event:not(.inbound, .internal, .email-event) > .message-evidence {
    inset-inline-start: calc(100% + calc(var(--space-1) * 2));
  }
  .shell-inbox .timeline-event:hover > .message-evidence,
  .shell-inbox .timeline-event > .message-evidence:focus-within,
  .shell-inbox .timeline-event > .message-evidence[open] {
    opacity: 1;
  }
  .shell-inbox .timeline-event > .message-evidence[open] {
    z-index: 5;
    padding: calc(var(--space-1) * 1.5) calc(var(--space-1) * 2);
    background: var(--surface);
    border: calc(var(--space-1) * 0.25) solid var(--ws-line);
    border-radius: var(--hub-field-radius);
  }

  /* Composer: fixed at the bottom, no own scroll.
     Row 1: [reply | note] toggle + channel scope + draft status
     Row 2: textarea (grows 1→5 lines) + attach + voice + send
     Row 3: delivery hint */
  .shell-inbox .conversation-editor {
    position: relative;
    flex: none;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto auto;
    align-items: center;
    column-gap: calc(var(--space-1) * 2);
    row-gap: calc(var(--space-1) * 1.5);
    max-height: none;
    overflow: visible;
    padding: calc(var(--space-1) * 2) calc(var(--space-1) * 4);
  }
  .shell-inbox .conversation-editor > .composer-tabs {
    grid-row: 1;
    grid-column: 1;
    display: inline-flex;
    gap: calc(var(--space-1) * 0.5);
    margin: 0;
    padding: calc(var(--space-1) * 0.5);
    background: var(--ws-soft);
    border-radius: var(--hub-field-radius);
  }
  .shell-inbox .conversation-editor > .composer-tabs button {
    height: calc(var(--space-1) * 6.5);
    min-height: calc(var(--space-1) * 6.5);
    padding: 0 calc(var(--space-1) * 2.5);
    font-size: var(--ic-meta);
    border: calc(var(--space-1) * 0.25) solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
  }
  .shell-inbox .conversation-editor > .composer-tabs button[aria-pressed='true'] {
    background: var(--surface);
    border-color: var(--ws-line);
  }
  .shell-inbox .conversation-editor > .draft-status {
    grid-row: 1;
    grid-column: 2 / -1;
    justify-self: end;
    max-width: 50%;
    margin: 0;
    font-size: var(--ic-meta);
    color: var(--ws-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .shell-inbox .conversation-editor > .transport-panel,
  .shell-inbox .conversation-editor > .internal-note-panel {
    grid-column: 1 / -1;
    margin: 0;
  }
  .shell-inbox .conversation-editor > .transport-panel > p {
    margin: 0;
    font-size: var(--ic-meta);
    line-height: calc(var(--space-1) * 4.5);
  }
  /* Reply form: flatten into the composer grid. */
  .shell-inbox .conversation-editor > .transport-panel:has(> .transport-composer:not([hidden])),
  .shell-inbox .conversation-editor .transport-composer:not([hidden]),
  .shell-inbox .conversation-editor .transport-composer .transport-submit {
    display: contents;
  }
  .shell-inbox .transport-composer > .composer-scope {
    grid-row: 1;
    grid-column: 2 / -1;
    justify-self: start;
    max-width: 50%;
    margin: 0;
    font-size: var(--ic-meta);
    color: var(--ws-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .shell-inbox .transport-composer > label {
    grid-row: 2;
    grid-column: 1 / 3;
    align-self: end;
    margin: 0;
    font-size: 0; /* "رد عبر القناة" stays as the accessible name */
  }
  .shell-inbox .transport-composer > .media-upload {
    grid-row: 2;
    grid-column: 3;
    align-self: end;
    margin: 0;
  }
  .shell-inbox .transport-composer > .voice-recorder {
    grid-row: 2;
    grid-column: 4;
    align-self: end;
    flex-wrap: nowrap;
    gap: var(--space-1);
    margin: 0;
  }
  .shell-inbox .transport-composer > .voice-recorder:has(audio:not([hidden])),
  .shell-inbox .transport-composer > .voice-recorder:has([data-note-stop]:not([hidden])) {
    grid-row: 3;
    grid-column: 1 / -1;
    flex-wrap: wrap;
  }
  .shell-inbox .transport-submit > button {
    grid-row: 2;
    grid-column: 5;
    align-self: end;
    height: var(--ic-input);
    min-height: var(--ic-input);
    margin: 0;
  }
  .shell-inbox .transport-submit > p {
    grid-row: 4;
    grid-column: 1 / -1;
    margin: 0;
    font-size: var(--ic-meta);
    line-height: calc(var(--space-1) * 4);
    color: var(--ws-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Attach + voice as compact ghost buttons on the same row. */
  .shell-inbox .conversation-editor .media-upload > summary {
    display: inline-flex;
    align-items: center;
    height: var(--ic-input);
    padding: 0 calc(var(--space-1) * 2.5);
    font-size: var(--type-ui-size);
    white-space: nowrap;
    border: calc(var(--space-1) * 0.25) solid var(--ws-line);
    border-radius: var(--hub-field-radius);
    background: var(--surface);
    list-style: none;
  }
  .shell-inbox .conversation-editor .media-upload > summary::-webkit-details-marker {
    display: none;
  }
  .shell-inbox .conversation-editor .media-upload[open] > label {
    position: absolute;
    bottom: calc(100% + var(--space-1));
    inset-inline: calc(var(--space-1) * 4);
    z-index: 30;
    display: grid;
    gap: calc(var(--space-1) * 2);
    padding: calc(var(--space-1) * 3);
    font-size: var(--ic-meta);
    background: var(--surface);
    border: calc(var(--space-1) * 0.25) solid var(--ws-line);
    border-radius: var(--hub-radius);
    box-shadow: var(--shadow-popover);
  }
  .shell-inbox .voice-recorder [data-note-start] {
    width: var(--ic-input);
    height: var(--ic-input);
    min-height: var(--ic-input);
    padding: 0;
    justify-content: center;
  }
  .shell-inbox .voice-recorder [data-note-start] > span {
    position: absolute;
    width: calc(var(--space-1) * 0.25);
    height: calc(var(--space-1) * 0.25);
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  /* Textarea: starts at one line, grows to five. */
  .shell-inbox .conversation-editor textarea {
    display: block;
    width: 100%;
    height: auto;
    min-height: var(--ic-input);
    max-height: calc(5 * calc(var(--space-1) * 5.25) + calc(var(--space-1) * 6.5));
    margin: 0;
    padding: calc(var(--space-1) * 3.25) calc(var(--space-1) * 3);
    font-size: var(--type-body-size);
    line-height: calc(var(--space-1) * 5.25);
    resize: none;
    overflow-y: auto;
    field-sizing: content;
  }
  /* Internal note panel (yellow identity kept). */
  .shell-inbox .conversation-editor .internal-note-panel[open] {
    padding: calc(var(--space-1) * 2);
  }
  .shell-inbox .conversation-editor .internal-note-panel:not([open]) > summary {
    font-size: var(--type-ui-size);
    padding: var(--space-1) 0;
  }
  /* Hub composer (#compose-form): used for demo/3CX conversations directly in the editor,
     and for internal notes inside .internal-note-panel.
     Row 1: [reply | note] toggle + scope line.  Last row: textarea + submit. */
  .shell-inbox .conversation-editor > .workspace-composer {
    grid-column: 1 / -1;
  }
  .shell-inbox .conversation-editor .workspace-composer {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: end;
    gap: calc(var(--space-1) * 1.5) calc(var(--space-1) * 2);
    margin: 0;
  }
  .shell-inbox .workspace-composer > * {
    grid-column: 1 / -1;
    margin: 0;
  }
  .shell-inbox .workspace-composer > .reply-modes:not([hidden]) {
    grid-row: 1;
    grid-column: 1;
    display: inline-flex;
    gap: calc(var(--space-1) * 0.5);
    padding: calc(var(--space-1) * 0.5);
    background: var(--ws-soft);
    border-radius: var(--hub-field-radius);
  }
  .shell-inbox .workspace-composer > .reply-modes button:not(.cu-btn) {
    height: calc(var(--space-1) * 6.5);
    min-height: calc(var(--space-1) * 6.5);
    padding: 0 calc(var(--space-1) * 2.5);
    margin: 0;
    font-size: var(--ic-meta);
    border-radius: var(--radius-sm);
  }
  .shell-inbox .workspace-composer > .reply-modes button:not(.primary):not(.cu-btn) {
    border-color: transparent;
    background: transparent;
  }
  .shell-inbox .workspace-composer > .hub-scope {
    grid-row: 1;
    grid-column: 2 / -1;
    align-self: center;
    padding: 0;
    font-size: var(--ic-meta);
    line-height: calc(var(--space-1) * 4);
    color: var(--ws-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: none;
    border: 0;
  }
  .shell-inbox .workspace-composer:has(> .reply-modes[hidden]) > .hub-scope {
    grid-column: 1 / -1;
  }
  /* "الرد أو الملاحظة" / "ملاحظة داخلية": the toggle already says it; keep it for screen readers. */
  .shell-inbox .workspace-composer > label[for='compose-kind'] {
    position: absolute;
    width: calc(var(--space-1) * 0.25);
    height: calc(var(--space-1) * 0.25);
    overflow: hidden;
    clip-path: inset(50%);
  }
  .shell-inbox .workspace-composer > label:not([for='compose-kind']) {
    font-size: var(--ic-meta);
  }
  .shell-inbox .workspace-composer > textarea {
    grid-column: 1 / 3;
  }
  .shell-inbox .workspace-composer > .section-title {
    grid-column: 3;
    display: flex;
    margin: 0;
    padding: 0;
    min-height: 0;
  }
  .shell-inbox .workspace-composer > .section-title small {
    display: none; /* channel already shown in the scope line */
  }
  .shell-inbox .workspace-composer > .section-title button {
    height: var(--ic-input);
    min-height: var(--ic-input);
    margin: 0;
  }
  /* Without the reply/note tabs, the review hint becomes the last line. */
  .shell-inbox .conversation-editor:not(:has(> .composer-tabs)) > .draft-status {
    grid-row: auto;
    grid-column: 1 / -1;
    justify-self: start;
    max-width: 100%;
  }

  /* ---------- 5. Customer context ---------- */
  .shell-inbox > .inbox-context {
    /* display is set only at ≥calc(var(--space-1) * 320) (see Widths); below that it stays hidden */
    flex-direction: column;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .shell-inbox > .inbox-context > * {
    flex: none;
  }
  /* Identity first, customer data second, then the rest. */
  .shell-inbox > .inbox-context > .context-overview,
  .shell-inbox > .inbox-context > .messenger-customer,
  .shell-inbox > .inbox-context > .whatsapp-customer {
    order: -2;
  }
  .shell-inbox > .inbox-context > [data-context-section='customer'] {
    order: -1;
  }
  .shell-inbox .inbox-context .context-section {
    padding: calc(var(--space-1) * 3);
    margin: 0;
  }
  .shell-inbox .inbox-context h3 {
    margin: 0 0 var(--space-1);
    font-size: var(--type-body-size);
    line-height: calc(var(--space-1) * 5);
  }
  .shell-inbox .inbox-context .section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: calc(var(--space-1) * 2);
    min-height: 0;
    margin: 0 0 var(--space-1);
    padding: 0;
  }
  .shell-inbox .inbox-context .section-title h3 {
    margin: 0;
  }
  .shell-inbox .inbox-context .section-title button,
  .shell-inbox .inbox-context .context-section button {
    height: calc(var(--space-1) * 7);
    min-height: calc(var(--space-1) * 7);
    padding: 0 calc(var(--space-1) * 2);
    font-size: var(--ic-meta);
  }
  .shell-inbox .inbox-context p,
  .shell-inbox .inbox-context small {
    font-size: var(--ic-meta);
    line-height: calc(var(--space-1) * 4.5);
  }
  .shell-inbox .inbox-context p.muted {
    margin: 0;
    color: var(--ws-muted);
  }
  .shell-inbox .inbox-context .identity-guard {
    margin: var(--space-1) 0 0;
    padding: calc(var(--space-1) * 1.5) calc(var(--space-1) * 2);
    font-size: var(--ic-meta);
    line-height: calc(var(--space-1) * 4.5);
  }
  .shell-inbox .inbox-context details > summary {
    font-size: var(--type-ui-size);
    padding: var(--space-1) 0;
  }
  .shell-inbox .inbox-context details.context-group > summary,
  .shell-inbox .inbox-context .transport-evidence > summary {
    min-height: 0;
    padding: calc(var(--space-1) * 2.5) calc(var(--space-1) * 3);
    font-size: var(--type-ui-size);
  }
  .shell-inbox .inbox-context .transport-evidence {
    padding: 0;
  }
  .shell-inbox .inbox-context .transport-evidence[open] {
    padding-bottom: calc(var(--space-1) * 2);
  }
  .shell-inbox .inbox-context .transport-evidence > :not(summary) {
    padding-inline: calc(var(--space-1) * 3);
  }
  /* Recent history: last two interactions only (the full thread is in the chat). */
  .shell-inbox .context-history-preview {
    display: block;
    margin: 0;
    padding: var(--space-1) 0;
    border: 0;
    background: none;
  }
  .shell-inbox .context-history-preview:nth-of-type(n + 3) {
    display: none;
  }
  .shell-inbox .context-history-preview small {
    display: block;
    font-size: var(--ic-meta);
    color: var(--ws-muted);
  }
  .shell-inbox .context-history-preview p {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .shell-inbox .inbox-context .customer-form {
    gap: calc(var(--space-1) * 2);
  }
  .shell-inbox .inbox-context .customer-form select,
  .shell-inbox .inbox-context .customer-form input {
    min-height: var(--ic-control);
    padding: var(--space-1) calc(var(--space-1) * 2);
    font-size: var(--type-ui-size);
  }
}

/* ---------- Widths ---------- */
/* 1280–1439: keep all three columns, narrower side columns.
   Fixes the empty 300px column at 1280–1350 (context hidden by workspace.css,
   while workspace-layout.js already moved its content into the side column). */
@media (min-width: 1280px) and (max-width: 1439px) {
  :root {
    --ic-queue: calc(var(--space-1) * 70);
    --ic-context: calc(var(--space-1) * 70);
  }
  .shell-inbox .workspace-brief-stage .tag,
  .shell-inbox .conversation-scope small {
    display: none;
  }
}
@media (min-width: 1280px) {
  body:not(:has(#call-dock[data-expanded='true'])) .hub-body .shell-inbox > .inbox-context {
    display: flex;
  }
}
@media (min-width: 761px) and (max-width: 1279px) {
  .hub-body .unified-layout.shell-inbox {
    grid-template-columns: calc(var(--space-1) * 70) minmax(0, 1fr);
  }
  .shell-inbox .workspace-brief-stage .tag,
  .shell-inbox .conversation-scope {
    display: none;
  }
}
/* Call panel open: keep the existing two-column behaviour. */
@media (min-width: 761px) {
  body:has(#call-dock[data-expanded='true']) .hub-body .unified-layout.shell-inbox {
    grid-template-columns: calc(var(--space-1) * 60) minmax(0, 1fr);
  }
  body:has(#call-dock[data-expanded='true']) .hub-body .shell-inbox > .inbox-context {
    display: none;
  }
}

/* ===================== Settings page ===================== */
/* Settings compact layout — load after workspace-redesign.css (and after inbox-compact.css if used).
   Presentation only: same colors, fonts, controls, forms and handlers. Desktop only (≥761px).
   Spacing scale: 4 / 8 / 12 / 16 / 24. Secondary text: 12px. Controls: 32px. */
:root {
  --sc-nav: calc(var(--space-1) * 55);
  --sc-control: calc(var(--space-1) * 8);
  --sc-content-max: calc(var(--space-1) * 295);
}

@media (min-width: 761px) {

  /* ---------- 5. Employees and teams ---------- */
  #management-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, calc(var(--space-1) * 85)), 1fr));
    align-items: start;
    gap: calc(var(--space-1) * 3);
  }
  #management-content > * {
    grid-column: 1 / -1;
    margin: 0;
  }
  #management-content > p {
    font-size: var(--type-meta-size);
  }
  /* Search + role filter on one line above the table. */
  #management-content > label {
    grid-column: auto;
    display: flex;
    align-items: center;
    gap: calc(var(--space-1) * 2);
    white-space: nowrap;
    font-size: var(--type-meta-size);
    justify-self: start;
  }
  /* The three "add" forms side by side instead of three full-width blocks. */
  #management-content > .shell-card {
    grid-column: auto;
    align-self: stretch;
  }
  #management-content > .shell-card form {
    max-width: none;
    gap: calc(var(--space-1) * 2);
  }
  #access-matrix th,
  #access-matrix td {
    padding: calc(var(--space-1) * 2) calc(var(--space-1) * 3);
  }
  /* Channel grants flow in columns instead of one long list per employee. */
  #access-matrix td:nth-child(3) {
    columns: 2 calc(var(--space-1) * 50);
    column-gap: calc(var(--space-1) * 6);
    white-space: normal;
    line-height: 1.6;
  }
  #access-matrix .employee-detail > summary {
    min-height: var(--sc-control);
  }
}

@media (min-width: 761px) and (max-width: 1279px) {
  :root {
    --sc-nav: calc(var(--space-1) * 46);
  }
}

/* ===================== Supervisor dashboard ===================== */
/* Supervisor dashboard compact layout — load after workspace-redesign.css.
   Presentation only: same colors, fonts, buttons and handlers. Desktop only (≥761px).
   Spacing scale: 4 / 8 / 12 / 16 / 24. Secondary text: 12px. Controls: 32px. */
:root {
  --sv-control: calc(var(--space-1) * 8);
}

@media (min-width: 761px) {
  /* ---------- 1. Page frame and heading ---------- */
  .shell-page:has(.supervisor-workspace) {
    padding: calc(var(--space-1) * 4) calc(var(--space-1) * 6) calc(var(--space-1) * 6);
  }
  .shell-page:has(.supervisor-workspace) > .shell-page-heading {
    display: flex;
    align-items: baseline;
    gap: calc(var(--space-1) * 3);
    min-width: 0;
  }
  .shell-page:has(.supervisor-workspace) > .shell-page-heading h1 {
    margin: 0;
    font-size: var(--type-page-title-size);
    line-height: calc(var(--space-1) * 7);
    flex: none;
  }
  .shell-page:has(.supervisor-workspace) > .shell-page-heading p {
    margin: 0;
    font-size: var(--type-meta-size);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .shell-page-body:has(> .supervisor-workspace) {
    margin-top: calc(var(--space-1) * 2);
  }
  .shell-page-body:has(> .supervisor-workspace) > p {
    margin: 0 0 calc(var(--space-1) * 2);
    font-size: var(--type-meta-size);
    color: var(--ws-muted);
  }
  .supervisor-workspace {
    display: grid;
    gap: calc(var(--space-1) * 2);
  }
  .supervisor-workspace > p {
    margin: 0;
    font-size: var(--type-meta-size);
  }

  /* ---------- 2. Toolbar: one 32px row, labels inline ---------- */
  .supervisor-workspace > .shell-tools {
    gap: calc(var(--space-1) * 3);
    margin: 0;
    align-items: center;
  }
  .supervisor-workspace > .shell-tools label {
    display: flex;
    align-items: center;
    gap: calc(var(--space-1) * 2);
    font-size: var(--type-meta-size);
    white-space: nowrap;
  }
  .supervisor-workspace > .shell-tools select,
  .supervisor-workspace > .shell-tools input {
    height: var(--sv-control);
    min-height: var(--sv-control);
    padding: 0 calc(var(--space-1) * 2);
    font-size: var(--type-ui-size);
  }
  .supervisor-workspace > .shell-tools input {
    width: calc(var(--space-1) * 65);
  }
  .supervisor-workspace > .shell-tools button {
    height: var(--sv-control);
    min-height: var(--sv-control);
    padding: 0 calc(var(--space-1) * 3);
    margin: 0;
    font-size: var(--type-ui-size);
  }
  .supervisor-workspace > .shell-tools small {
    font-size: var(--type-meta-size);
  }

  /* ---------- 3. Company summary: number next to its label ---------- */
  .supervisor-company-summary.shell-grid {
    gap: calc(var(--space-1) * 2);
  }
  .supervisor-company-summary .shell-card {
    margin: 0;
    padding: calc(var(--space-1) * 3) calc(var(--space-1) * 4);
  }
  .supervisor-company-summary .shell-card h3 {
    margin: 0 0 calc(var(--space-1) * 2);
    font-size: var(--type-body-size);
  }
  .supervisor-company-summary .shell-metrics {
    grid-template-columns: repeat(4, minmax(0, auto));
    justify-content: start;
    gap: var(--space-1) 0;
    margin: 0;
  }
  .supervisor-company-summary .shell-metrics dt {
    font-size: var(--type-meta-size);
    color: var(--ws-muted);
    white-space: nowrap;
    padding-inline-end: calc(var(--space-1) * 2);
  }
  .supervisor-company-summary .shell-metrics dd {
    font-size: var(--type-message-size);
    padding-inline-end: calc(var(--space-1) * 8);
    font-variant-numeric: tabular-nums;
  }

  /* ---------- 4. Work metrics: one compact row of filter buttons ---------- */
  .supervisor-now.shell-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: calc(var(--space-1) * 2);
  }
  .supervisor-now .supervisor-metric {
    display: flex;
    align-items: baseline;
    gap: calc(var(--space-1) * 2);
    min-height: 0;
    margin: 0;
    padding: calc(var(--space-1) * 2) calc(var(--space-1) * 3);
    text-align: start;
  }
  .supervisor-now .supervisor-metric b {
    font-size: var(--type-page-title-size);
    line-height: calc(var(--space-1) * 7);
    font-variant-numeric: tabular-nums;
  }
  .supervisor-now .supervisor-metric span {
    font-size: var(--type-meta-size);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  .supervisor-definitions > summary {
    font-size: var(--type-meta-size);
  }
}

/* 1280–1439: tighter columns, still one line per conversation. */
@media (min-width: 761px) and (max-width: 1439px) {
  .supervisor-company-summary .shell-metrics dd {
    padding-inline-end: calc(var(--space-1) * 5);
  }
}
@media (min-width: 761px) and (max-width: 1199px) {
  .supervisor-now.shell-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Care workstation refinement: readable hierarchy and task-led layouts. */
.shell-inbox .workspace-brief-next {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: calc(var(--space-1) * 0.5);
}
.shell-inbox .workspace-brief-next small {
  white-space: normal;
}
.care-journey-progress {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--space-1) * 2);
  padding: calc(var(--space-1) * 3) calc(var(--space-1) * 4);
}
.embedded-journey > .care-journey-progress {
  display: flex;
}

.care-journey-progress span {
  padding: calc(var(--space-1) * 2) calc(var(--space-1) * 3);
  border: calc(var(--space-1) * 0.25) solid var(--ws-line);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: var(--type-body-size);
}
.care-journey-progress [aria-current='step'] {
  background: var(--brand-50);
  border-color: var(--ws-brand);
  font-weight: 600;
}
.shell-inbox .conversation-editor:has(.knowledge-answer-tools) {
  max-height: min(45vh, calc(var(--space-1) * 105));
  overflow-y: auto;
}
:root {
  --ic-nav: calc(var(--space-1) * 26);
  --ic-queue: calc(var(--space-1) * 85);
  --ic-context: calc(var(--space-1) * 75);
}

@media (min-width: 761px) and (max-width: 1100px) {
  body:has(#call-dock[data-expanded='true']) .hub-body .unified-layout.shell-inbox {
    grid-template-columns: minmax(0, 1fr);
  }
}
body {
  font-size: var(--type-message-size);
  line-height: 1.6;
}
button,
input,
select,
textarea {
  font: inherit;
}
.care-form-guidance {
  color: var(--ink-muted);
  font-size: var(--type-body-size);
  line-height: 1.7;
}
.journey-create {
  max-width: calc(var(--space-1) * 170);
  margin-inline: auto;
  padding: calc(var(--space-1) * 6);
}
.journey-create label {
  display: grid;
  gap: calc(var(--space-1) * 2);
  margin-block: calc(var(--space-1) * 4);
}
.hub-empty {
  max-width: calc(var(--space-1) * 170);
  margin: calc(var(--space-1) * 8) auto;
  padding: calc(var(--space-1) * 6);
  line-height: 1.8;
}
#work-views.saved-views {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--space-1) * 2);
  margin-block: calc(var(--space-1) * 4);
}
#work-views.saved-views button {
  width: auto;
  flex: 0 1 auto;
  min-height: calc(var(--space-1) * 10);
  margin: 0;
  padding: calc(var(--space-1) * 2) calc(var(--space-1) * 3.5);
  font-size: var(--type-body-size);
}
.care-rota-grid {
  overflow: auto;
  margin-block: calc(var(--space-1) * 4);
}
.care-rota-grid table {
  min-width: calc(var(--space-1) * 195);
}
.care-rota-grid caption {
  text-align: start;
  padding: calc(var(--space-1) * 3);
  font-size: var(--type-body-size);
}
.care-rota-grid button {
  min-height: calc(var(--space-1) * 9);
  margin: calc(var(--space-1) * 0.5);
  padding: var(--space-1) calc(var(--space-1) * 2);
  font-size: var(--type-ui-size);
  direction: ltr;
}
.care-shift-editor {
  margin-block: calc(var(--space-1) * 2);
  border: calc(var(--space-1) * 0.25) solid var(--ws-line);
  border-radius: var(--radius-md);
}
.care-shift-editor > summary {
  padding: calc(var(--space-1) * 3);
  cursor: pointer;
  font-size: var(--type-body-size);
}
.care-shift-editor[open] {
  border-color: var(--ws-brand);
  background: var(--canvas-subtle);
}
.care-draft-actions {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--space-1) * 4);
  padding: calc(var(--space-1) * 4);
  border-top: calc(var(--space-1) * 0.25) solid var(--ws-line);
  background: var(--canvas-subtle);
}
.care-draft-actions span {
  font-size: var(--type-body-size);
}
@media (min-width: 761px) {
  .hub-body .shell-nav a {
    width: 100%;
    height: auto;
    min-height: calc(var(--space-1) * 16);
    padding: calc(var(--space-1) * 2) var(--space-1);
    font-size: var(--type-ui-size);
    line-height: calc(var(--space-1) * 5);
  }
  .shell-nav [data-nav-size] {
    min-height: calc(var(--space-1) * 9);
    width: 100%;
    padding: var(--space-1);
    margin: 0 0 calc(var(--space-1) * 2);
    font-size: var(--type-meta-size);
    white-space: normal;
  }
  body[data-nav-expanded='true'] .hub-body {
    grid-template-columns: calc(var(--space-1) * 56) minmax(0, 1fr);
  }
  body[data-nav-expanded='true'] .hub-body .shell-nav a {
    display: flex;
    align-items: center;
    gap: calc(var(--space-1) * 3);
    text-align: start;
    white-space: normal;
    min-height: calc(var(--space-1) * 12);
  }
  body[data-nav-expanded='true'] .shell-nav .nav-symbol {
    flex: 0 0 calc(var(--space-1) * 5.5);
    margin: 0;
  }
  .shell-inbox .queue-row {
    padding: calc(var(--space-1) * 3) calc(var(--space-1) * 4);
    row-gap: var(--space-1);
  }
  .shell-inbox .queue-row-heading strong {
    font-size: var(--type-message-size);
    line-height: calc(var(--space-1) * 6);
  }
  .shell-inbox .queue-preview {
    font-size: var(--type-body-size);
    line-height: calc(var(--space-1) * 5.5);
  }
  .shell-inbox .saved-views button,
  .shell-inbox .queue-filters select,
  .shell-inbox .extra-filters > summary {
    min-height: calc(var(--space-1) * 9);
    height: auto;
    font-size: var(--type-ui-size);
  }
  .shell-inbox .workspace-brief {
    min-height: calc(var(--space-1) * 22);
    gap: calc(var(--space-1) * 2) calc(var(--space-1) * 4);
    padding: calc(var(--space-1) * 3) calc(var(--space-1) * 4);
  }
  .shell-inbox .workspace-brief-next p {
    white-space: normal;
    overflow: visible;
    font-size: var(--type-body-size);
    line-height: calc(var(--space-1) * 5.5);
  }
  .shell-inbox .workspace-brief-link {
    min-height: calc(var(--space-1) * 9);
    height: auto;
    font-size: var(--type-ui-size);
    padding: calc(var(--space-1) * 1.5) calc(var(--space-1) * 3);
  }
  .shell-inbox .workspace-brief-stage {
    align-items: center;
  }
  .shell-inbox .conversation-scroll {
    padding-inline: clamp(calc(var(--space-1) * 4), 4vw, calc(var(--space-1) * 16));
  }
  .shell-inbox .conversation-scroll > .message {
    max-width: calc(var(--space-1) * 180);
  }
  .shell-inbox .conversation-heading {
    flex-wrap: wrap;
    gap: calc(var(--space-1) * 2) calc(var(--space-1) * 4);
    padding-block: calc(var(--space-1) * 3);
  }
  .shell-inbox .conversation-actions button {
    min-height: calc(var(--space-1) * 9);
    font-size: var(--type-ui-size);
  }
  .shell-inbox .inbox-context h3 {
    font-size: var(--type-message-size);
  }
  .shell-inbox .context-section > summary {
    font-size: var(--type-body-size);
    min-height: calc(var(--space-1) * 10);
  }
  .supervisor-company-summary.shell-grid {
    grid-template-columns: repeat(auto-fit, minmax(calc(var(--space-1) * 65), calc(var(--space-1) * 105)));
    justify-content: start;
    gap: calc(var(--space-1) * 4);
  }
  .supervisor-company-summary .shell-card {
    min-height: 0;
    padding: calc(var(--space-1) * 4);
  }
  .supervisor-company-summary .shell-metrics {
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: stretch;
  }
  .supervisor-company-summary .shell-metrics dd {
    padding-inline-end: 0;
  }
  .supervisor-now .supervisor-metric span {
    white-space: normal;
    line-height: calc(var(--space-1) * 5);
    font-size: var(--type-ui-size);
  }
}

@media (min-width: 761px) and (max-width: 1399px) {
  :root {
    --ic-queue: calc(var(--space-1) * 80);
    --ic-context: calc(var(--space-1) * 70);
  }
  body[data-nav-expanded='true'] .hub-body {
    grid-template-columns: calc(var(--space-1) * 46) minmax(0, 1fr);
  }
}
@media (max-width: 760px) {
  .shell-nav [data-nav-size] {
    display: none;
  }
  .care-draft-actions {
    flex-direction: column;
    align-items: stretch;
    padding: calc(var(--space-1) * 3);
  }
  .care-draft-actions button {
    width: 100%;
  }
  .journey-create {
    padding: calc(var(--space-1) * 4);
  }
}

/* Phase 1: layout of existing Care components; all dimensions derive from tokens. */
.shell-inbox .inbox-main {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}
.shell-inbox .inbox-main::before,
.shell-inbox .inbox-main::after { display: none; }
.shell-inbox .conversation-heading {
  display: flex;
  flex: none;
  align-items: center;
  flex-wrap: nowrap;
  gap: var(--space-2);
  min-height: var(--input-lg);
  padding: var(--space-1) var(--space-3);
  background: var(--surface);
  z-index: 45;
}
.shell-inbox .conversation-heading .customer-name {
  flex: 0 1 auto;
  margin: 0;
  padding: 0;
  max-width: 30%;
}
.shell-inbox .conversation-heading h2 { display: block; margin: 0; white-space: nowrap; }
.shell-inbox .conversation-scope {
  flex: 1;
  padding: 0;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shell-inbox .conversation-heading .actions { flex: none; flex-wrap: nowrap; margin: 0; gap: var(--space-1); }
.shell-inbox .workspace-brief {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--space-2);
  min-height: calc(var(--control-md) + var(--space-1));
  height: calc(var(--control-md) + var(--space-1));
  margin: 0;
  padding: 0 var(--space-3);
  overflow: visible;
  position: relative;
}
.shell-inbox .workspace-brief-stage { display: none; }
.shell-inbox .workspace-brief-next {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
}
.shell-inbox .workspace-brief-next > small { display: none; }
.shell-inbox .workspace-brief-next p,
.shell-inbox .workspace-brief[data-expanded='true'] .workspace-brief-next p {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shell-inbox .workspace-brief[data-expanded='true'] .workspace-brief-next {
  position: absolute;
  inset-inline: var(--space-3);
  top: 100%;
  z-index: 40;
  background: var(--surface);
  box-shadow: var(--shadow-popover);
  padding: var(--space-3);
}
.shell-inbox .workspace-brief[data-expanded='true'] .workspace-brief-next p { white-space: normal; }
.shell-inbox .workspace-brief-link { margin: 0; flex: none; }
.shell-inbox .customer-tabs {
  display: flex;
  flex: none;
  align-items: center;
  flex-wrap: nowrap;
  gap: var(--space-1);
  height: calc(var(--control-md) + var(--space-2));
  min-height: calc(var(--control-md) + var(--space-2));
  margin: 0;
  padding: var(--space-1) var(--space-3);
  background: var(--surface);
}
.shell-inbox .customer-tabs .channel-switch {
  display: flex;
  gap: var(--space-1);
  margin: 0;
  margin-inline-start: auto;
  padding: 0;
  border: 0;
}
.shell-inbox .inbox-main > .main-pane { flex: 1; min-height: 0; }
.unified-layout.shell-inbox[data-tab='chat'] .pane-chat { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.shell-inbox .conversation-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.shell-inbox .conversation-editor {
  display: block;
  flex: none;
  padding: var(--space-2) var(--space-3);
  max-height: none;
}
.shell-inbox .conversation-editor .workspace-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-1) var(--space-2);
  margin: 0;
}
.shell-inbox .workspace-composer > label[for='compose-kind'],
.shell-inbox .workspace-composer > p.muted { display: none; }
.shell-inbox .workspace-composer > .reply-modes:not([hidden]) {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  background: none;
  grid-row: 1;
}
.shell-inbox .composer-scope { min-width: 0; margin: 0; margin-inline-start: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-inbox .workspace-composer > label:not([for='compose-kind']) { display: none; }
.shell-inbox .inbox-composer-tools { position: relative; flex: none; }
.shell-inbox .inbox-composer-tools > label {
  position: absolute;
  bottom: 100%;
  inset-inline-start: 0;
  min-width: var(--side-menu);
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--surface);
  border: calc(var(--space-1) * 0.25) solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
  z-index: 40;
}
.shell-inbox .conversation-editor .workspace-composer > .section-title button {
  flex: none;
  width: auto;
  height: var(--control-lg);
  min-height: var(--control-lg);
  padding-inline: var(--space-4);
}
.shell-inbox .conversation-scope .presence-warning { display: inline-flex; margin: 0; max-width: 100%; }
.shell-inbox .conversation-scope .presence-warning:empty { display: none; }
.shell-inbox .workspace-composer > textarea {
  grid-column: 1;
  grid-row: 2;
  height: auto;
  min-height: var(--input-lg);
  max-height: calc(var(--space-8) * 5);
  field-sizing: content;
  padding: var(--space-2) var(--space-3);
  resize: none;
}
.shell-inbox .workspace-composer > .section-title { display: flex; grid-column: 2; grid-row: 2; margin: 0; }
.shell-inbox .workspace-composer > .section-title small { display: none; }
.shell-inbox .draft-status:empty { display: none; }
.shell-inbox .queue-title {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: none;
  margin: 0;
  padding: var(--space-1);
  min-height: var(--control-lg);
}
.shell-inbox .queue-title h1 { flex: none; margin: 0; }
.shell-inbox .queue-title .saved-views { display: flex; flex: 1; gap: var(--space-1); padding: 0; margin: 0; }
.shell-inbox .queue-title .saved-views button { flex: none; width: auto; padding-inline: var(--space-1); }
.shell-inbox .queue-title #new-lead { display: inline-flex; width: auto; padding-inline: var(--space-1); margin: 0; font-size: inherit; }
.shell-inbox #new-lead::before { content: none; }
.shell-inbox .queue-title .extra-filters { border: 0; margin: 0; padding: 0; position: static; }
.shell-inbox .queue-title .extra-filters[open]::details-content {
  position: absolute;
  inset-inline: var(--space-2);
  top: var(--control-lg);
  z-index: 30;
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--surface);
  border: calc(var(--space-1) * 0.25) solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
}
.shell-inbox .queue-filters:empty,
.shell-inbox .queue-tools { display: none; }
.shell-inbox .workspace-update-status { padding: 0 var(--space-2); margin: 0; }
.shell-inbox .queue-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  height: calc(var(--input-lg) + var(--space-6));
  min-height: calc(var(--input-lg) + var(--space-6));
  padding: var(--space-1) var(--space-3);
}
.shell-inbox .queue-row-heading { display: flex; gap: var(--space-2); min-width: 0; }
.shell-inbox .queue-row-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-inbox .queue-row-heading .queue-time { margin-inline-start: auto; flex: none; }
.shell-inbox .queue-row .queue-preview { flex: none; margin: 0; height: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell-inbox .queue-row-footer { display: flex; align-items: center; gap: var(--space-1); min-width: 0; }
.shell-inbox .queue-row-footer .queue-company { flex: 1; min-width: 0; }
.shell-inbox .queue-row-footer .queue-owner:empty { display: none; }
.shell-inbox .queue-row-footer .queue-overdue { max-width: none; }
@media (min-width: 761px) {
  .hub-body .unified-layout.shell-inbox { grid-template-columns: calc(var(--side-menu) * 2 + var(--nav-rail)) minmax(0, 1fr) calc(var(--side-menu) + var(--nav-rail) + var(--space-1)); }
  .hub-body .unified-layout.shell-inbox[data-context-collapsed='true'] { grid-template-columns: calc(var(--side-menu) * 2 + var(--nav-rail)) minmax(0, 1fr); }
  body:not(:has(#call-dock[data-expanded='true'])) .hub-body .shell-inbox[data-context-collapsed='true'] > .inbox-context { display: none; }
  .shell-inbox .customer-tabs [data-tab='customer'] { display: inline-flex; }
}
@media (max-width: 760px) {
  body:has(.shell-inbox) { height: 100dvh; overflow: hidden; }
  body:has(.shell-inbox) .hub-top {
    height: calc(var(--control-lg) + var(--control-sm));
    min-height: calc(var(--control-lg) + var(--control-sm));
    padding-block: 0;
    row-gap: 0;
  }
  body:has(.shell-inbox) .hub-top .care-brand { max-height: var(--control-sm); }
  .hub-body .unified-layout.shell-inbox { height: 100%; min-height: 0; }
  .shell-inbox .conversation-heading .customer-name { max-width: none; flex: 1; }
  .shell-inbox .conversation-heading > .cu-tag { display: none; }
  .shell-inbox .conversation-heading .actions { margin: 0; width: auto; min-width: 0; }
  .shell-inbox .conversation-heading #back-inbox { width: auto; white-space: nowrap; padding-inline: var(--space-2); }
  .shell-inbox .conversation-heading .actions > .conversation-actions > summary { white-space: nowrap; }
  .shell-inbox .workspace-brief { display: flex; padding-inline: var(--space-2); }
  .shell-inbox .workspace-brief .workspace-brief-next,
  .shell-inbox .workspace-brief .workspace-brief-stage { display: none; }
  .shell-inbox .workspace-brief .workspace-brief-link { display: inline-flex; }
  .shell-inbox .workspace-brief[data-expanded='true'] .workspace-brief-next { display: flex; }
  .shell-inbox .customer-tabs { padding-inline: var(--space-1); }
  .shell-inbox .customer-tabs button { padding-inline: var(--space-1); }
  .shell-inbox .conversation-editor:not(:focus-within) .workspace-composer > .reply-modes:not([hidden]) { display: none; }
  .shell-inbox .conversation-editor { padding: var(--space-1) var(--space-2); }
  .shell-inbox .workspace-composer > textarea,
  .shell-inbox .workspace-composer > .section-title { grid-row: 2; }
  .shell-inbox .queue-title { flex-wrap: wrap; }
  .shell-inbox .queue-title .saved-views { order: 2; flex-basis: 100%; }
}

/* Keep readable metadata and minimum targets across legacy selectors. */
.shell-inbox :is(.tag, .cu-tag, .queue-title > span, .conversation-editor button) {
  font-size: var(--space-3) !important;
}
body:has(.shell-inbox) .hub-top .tag,
body:has(.shell-inbox) .workspace-demo {
  font-size: var(--space-3);
}
.shell-inbox .customer-name > summary,
.shell-inbox .message-evidence > summary {
  display: flex;
  align-items: center;
  min-height: var(--space-6);
  min-width: var(--space-6);
}

.shell-inbox #back-inbox[hidden] { display: none; }

/* Emoji picker in the reply and note composers. */
.conversation-editor > .cu-emoji { position: relative; display: inline-flex; vertical-align: middle; margin-inline-start: var(--space-2); }
.conversation-editor > .cu-emoji .cu-emoji__trigger { inline-size: var(--control-md); min-inline-size: 0; padding-inline: 0; font-size: 16px; }
.conversation-editor > .cu-emoji .cu-emoji__panel { position: absolute; inset-block-end: calc(100% + var(--space-1)); inset-inline-start: 0; z-index: 5; display: grid; grid-template-columns: repeat(8, var(--control-md)); gap: var(--space-1); max-inline-size: calc(100vw - var(--space-6)); padding: var(--space-2); background: var(--surface); border: var(--stroke-thin) solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-popover); }
.conversation-editor > .cu-emoji .cu-emoji__panel[hidden] { display: none; }
.conversation-editor > .cu-emoji .cu-emoji__panel button { inline-size: var(--control-md); min-inline-size: 0; block-size: var(--control-md); min-block-size: 0; padding: 0; margin: 0; border: 0; border-radius: var(--radius-sm); background: transparent; font-size: 20px; line-height: 1; cursor: pointer; }
.conversation-editor > .cu-emoji .cu-emoji__panel button:hover, .conversation-editor > .cu-emoji .cu-emoji__panel button:focus-visible { background: var(--canvas-subtle); }
@media (max-width: 760px) { .conversation-editor > .cu-emoji .cu-emoji__panel { grid-template-columns: repeat(6, var(--control-md)); } }
