/* ═══════════════════════════════════════════════════════════
   App Rail (shared between main app and inbox)
   ═══════════════════════════════════════════════════════════ */

.super-shell {
  display: flex;
  min-height: 100vh;
}

/* Header height 48px + sidebar padding 18px = 66px — rail icons align with first sidebar item */
.app-rail {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 56px;
  background: #2d457f;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 66px 0 8px 0;
  z-index: 50;
}

.app-rail-top,
.app-rail-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.app-rail-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px;
  border-radius: 10px;
  color: rgba(248, 250, 252, 0.6);
  transition: all 0.15s ease;
  text-decoration: none;
  position: relative;
}

.app-rail-icon:hover {
  color: #f8fafc;
  background: rgba(248, 250, 252, 0.1);
}

.app-rail-icon.is-active {
  color: #f8fafc;
  background: rgba(248, 250, 252, 0.15);
}

.app-rail-icon svg {
  width: 22px;
  height: 22px;
}

.app-rail-label {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  line-height: 1;
}

.app-rail-badge {
  position: absolute;
  top: 4px;
  right: 2px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

/* ── Shift the entire main app shell to make room for the rail ── */

/* The rail occupies the left 56px of the viewport.  Remove the body's
   left padding so everything aligns flush against the rail edge. */
body.pp-body {
  padding-left: 0;
}

.super-shell .app-shell {
  margin-left: 56px;
  flex: 1;
  min-width: 0;
}

/* Fixed-position elements: re-anchor to the rail's right edge (56px)
   instead of the old var(--shell-gutter). */
.super-shell .header-bar {
  left: 56px;
}

.super-shell .sidebar {
  left: 56px;
}

.super-shell .sidebar-corner {
  left: 56px;
}

.super-shell .sidebar-hover-zone {
  left: 56px;
}

/* ═══════════════════════════════════════════════════════════
   Inbox body: match main app (blue gutters left/right via padding)
   ═══════════════════════════════════════════════════════════ */

body.pp-body-inbox {
  padding-left: 0;
  padding-right: var(--shell-gutter);
  background: #2d457f;
}

/* Inbox page: fixed viewport height so columns can scroll independently */
.inbox-page-shell {
  margin-left: 56px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  padding-top: 48px;
  overflow: hidden;
}

/* Reuse .main from application.css; add full rounded corners for inbox (no sidebar) */
.pp-body-inbox .inbox-page-shell .main {
  border-radius: 16px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inbox-page-shell .inbox-shell {
  margin-left: 0;
  height: 100%;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════
   Inbox Shell (four-column layout)
   ═══════════════════════════════════════════════════════════ */

.inbox-shell {
  margin-left: 56px;
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 220px 320px 1fr 340px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

/* Grid items need min-height: 0 so columns can shrink and scroll independently */
.inbox-shell > .inbox-filter-sidebar,
.inbox-shell > .inbox-thread-list,
.inbox-shell > .inbox-thread-detail,
.inbox-shell > .inbox-context-sidebar {
  min-height: 0;
}

/* Filter sidebar: whole column scrolls */
.inbox-shell > .inbox-filter-sidebar {
  overflow-y: auto;
  overflow-x: hidden;
}

/* Thread list: column uses overflow hidden; .inbox-thread-list-items scrolls inside */
.inbox-shell > .inbox-thread-list {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Thread detail: whole column scrolls (header, messages, then compose at bottom of content) */
.inbox-shell > .inbox-thread-detail {
  overflow-y: auto;
  overflow-x: hidden;
}

/* Context sidebar: whole column scrolls */
.inbox-shell > .inbox-context-sidebar {
  overflow-y: auto;
  overflow-x: hidden;
}

/* Composing: hide thread list and context sidebar, full-width compose, less top gap */
.inbox-shell.is-composing {
  grid-template-columns: 220px minmax(0, 1fr);
  padding-top: 0;
  height: 100vh;
  width: 100%;
}
.inbox-shell.is-composing .inbox-thread-list,
.inbox-shell.is-composing .inbox-context-sidebar {
  display: none;
}
.inbox-shell.is-composing .inbox-thread-detail {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}
.inbox-shell.is-composing .inbox-detail-header,
.inbox-shell.is-composing .inbox-compose--standalone {
  max-width: 100%;
}

/* ── Filter sidebar (Column A) ───────────────────────────── */

.inbox-filter-sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  border-top-left-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.inbox-filter-header {
  padding: 16px 16px 8px;
  border-bottom: 1px solid var(--line);
}

.inbox-filter-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.inbox-filter-search {
  padding: 8px 12px;
}

.inbox-filter-search-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12.5px;
  background: var(--soft);
  color: var(--ink);
  outline: none;
}

.inbox-filter-search-input:focus {
  border-color: var(--accent);
  background: #fff;
}

.inbox-filter-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 16px;
}

.inbox-filter-group {
  margin-bottom: 12px;
}

.inbox-filter-group-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 8px 8px 4px;
  margin: 0;
}

.inbox-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s ease;
}

.inbox-filter-item:hover {
  background: var(--soft);
}

.inbox-filter-item.is-active {
  background: var(--accent-weak);
  color: var(--accent);
  font-weight: 500;
}

.inbox-filter-item-icon {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.inbox-filter-item-icon svg {
  width: 16px;
  height: 16px;
}

.inbox-filter-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  background: var(--soft);
  color: var(--muted);
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.inbox-filter-item.is-active .inbox-filter-count {
  background: var(--accent);
  color: #fff;
}

.inbox-filter-vendor-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.inbox-filter-vendor-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Thread list (Column B) ──────────────────────────────── */

.inbox-thread-list {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inbox-thread-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.inbox-thread-list-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.inbox-thread-list-items {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.inbox-thread-list-empty {
  padding: 40px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* Thread row */
.inbox-thread-row {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.1s ease;
  text-decoration: none;
  color: inherit;
}

.inbox-thread-row:hover {
  background: var(--soft);
}

.inbox-thread-row.is-selected {
  background: var(--accent-weak);
}

.inbox-thread-row.is-unread {
  background: #fefce8;
}

.inbox-thread-row.is-unread.is-selected {
  background: var(--accent-weak);
}

.inbox-thread-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.inbox-thread-row-body {
  flex: 1;
  min-width: 0;
}

.inbox-thread-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.inbox-thread-row-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.is-unread .inbox-thread-row-name {
  color: #111827;
}

.inbox-thread-row-time {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.inbox-thread-row-subject {
  font-size: 12.5px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}

.is-unread .inbox-thread-row-subject {
  font-weight: 500;
}

.inbox-thread-row-snippet {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-thread-row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.inbox-thread-row-badge {
  font-size: 10px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--soft);
  color: var(--muted);
}

.inbox-unread-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* ── Thread detail (Column C) — Gorgias-style ───────────────── */

.inbox-thread-detail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
}

.inbox-detail-header {
  padding: 20px 24px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.inbox-detail-header-left {
  min-width: 0;
  flex: 1;
}

.inbox-detail-subject {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.inbox-detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.inbox-detail-meta a {
  color: var(--accent);
  text-decoration: none;
}

.inbox-detail-meta a:hover {
  text-decoration: underline;
}

.inbox-detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-shrink: 0;
}

.inbox-detail-action-btn {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
}

.inbox-detail-action-btn:hover {
  background: var(--soft);
  border-color: var(--muted);
}

.inbox-detail-action-btn svg {
  width: 16px;
  height: 16px;
}

/* Message stream — no padding on the stream itself; each message owns its own padding */
.inbox-message-stream {
  flex: 0 0 auto;
  min-width: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: #fff;
}

.inbox-message {
  display: block;
  border-bottom: 1px solid var(--line);
  padding: 16px 24px 20px;
  margin: 0;
  transition: background-color 0.15s ease;
}

.inbox-message:hover {
  background-color: #f9fafb;
}

.inbox-message:last-child {
  border-bottom: none;
}

/* Collapsible message header row — always visible, acts as the click target */
.inbox-message-header-row {
  cursor: pointer;
  user-select: none;
}

.inbox-message-header-row:hover {
  /* subtle cue that the row is clickable */
}

.inbox-message-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0;
}

.inbox-message-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Snippet shown only when message is collapsed */
.inbox-message-snippet {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  margin-top: 3px;
  display: none; /* hidden by default; shown in collapsed state */
}

/* Chevron icon — rotates when expanded */
.inbox-message-chevron {
  display: flex;
  align-items: center;
  color: var(--muted);
  transition: transform 0.18s ease, opacity 0.18s;
  opacity: 0;
}

.inbox-message-header-row:hover .inbox-message-chevron,
.inbox-message.is-collapsed .inbox-message-chevron {
  opacity: 1;
}

.inbox-message-chevron svg {
  width: 14px;
  height: 14px;
  transition: transform 0.18s ease;
}

/* Rotated (pointing up) when expanded */
.inbox-message:not(.is-collapsed) .inbox-message-chevron svg {
  transform: rotate(180deg);
}

/* Attachment indicator badge shown in the collapsed header */
.inbox-message-has-attachments {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
  display: none; /* only shown when collapsed */
}

.inbox-message-has-attachments svg {
  width: 12px;
  height: 12px;
}

/* ── Collapsed state ── */
.inbox-message.is-collapsed {
  padding-bottom: 14px;
}

.inbox-message.is-collapsed .inbox-message-header-row {
  margin-bottom: 0;
}

.inbox-message.is-collapsed .inbox-message-snippet {
  display: block;
}

.inbox-message.is-collapsed .inbox-message-has-attachments {
  display: inline-flex;
}

.inbox-message.is-collapsed .inbox-message-bubble {
  display: none;
}

/* ── Expanded state — add spacing back between header row and body ── */
.inbox-message:not(.is-collapsed) .inbox-message-header-row {
  margin-bottom: 8px;
}

/* Expand/collapse all — Gmail-style icon buttons, positioned top-right of header */
.inbox-detail-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.inbox-detail-header-icons {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-top: 2px;
}

.inbox-icon-btn {
  background: none;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
  padding: 0;
}

.inbox-icon-btn:hover {
  background: var(--soft);
  color: var(--ink);
}

.inbox-message-avatar {
  display: none;
}

.inbox-message-bubble {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.inbox-message-outbound .inbox-message-bubble {
  background: transparent;
  border: none;
  color: var(--ink);
}

.inbox-message-note .inbox-message-bubble {
  background: transparent;
  border: none;
  color: #78350f;
}

.inbox-message-sender {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}

.inbox-message-outbound .inbox-message-sender {
  color: var(--ink);
}

.inbox-message-time {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  flex-shrink: 0;
}

.inbox-message-outbound .inbox-message-time {
  color: var(--muted);
}

.inbox-message-body {
  font-size: 15px;
  line-height: 1.55;
  word-break: break-word;
  color: var(--ink);
}

.inbox-message-outbound .inbox-message-body {
  color: var(--ink);
}

.inbox-message-body p {
  margin: 0 0 6px;
}

.inbox-message-body p:last-child {
  margin-bottom: 0;
}

/* Collapsed quoted reply (On ... wrote:, blockquotes) */
.inbox-message-body details.collapse-quoted {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.inbox-message-body .collapse-quoted-summary {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.inbox-message-body .collapse-quoted-summary:hover {
  color: var(--ink);
  background: var(--soft);
}

.inbox-message-body .collapse-quoted-summary::-webkit-details-marker {
  display: none;
}

.inbox-message-body details.collapse-quoted[open] .collapse-quoted-summary {
  border-bottom: 1px solid var(--line);
}

.inbox-message-body details.collapse-quoted > *:not(summary) {
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 13px;
  color: var(--muted);
}

/* Attachment list below a message body */
.inbox-message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.inbox-attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink);
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
  max-width: 260px;
}

.inbox-attachment-pill:hover {
  background: #e8eaf0;
  border-color: #b0b8c8;
  color: var(--ink);
  text-decoration: none;
}

.inbox-attachment-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--muted);
}

.inbox-attachment-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-attachment-size {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.inbox-attachment-download-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.12s;
}

.inbox-attachment-pill:hover .inbox-attachment-download-icon {
  opacity: 1;
}

/* Attachment wrap: pill + split chevron as one visual unit */
.inbox-attachment-wrap {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  max-width: 300px;
}

/* When importable, flatten the right side of the pill to join with the chevron */
.inbox-attachment-wrap.has-actions .inbox-attachment-pill {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}

/* Hide the download arrow on importable pills — the chevron takes its place */
.inbox-attachment-wrap.has-actions .inbox-attachment-download-icon {
  display: none;
}

/* Split-button chevron — always visible, attached to the right side of the pill */
.inbox-attachment-actions-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  border: 1px solid var(--line);
  border-left: 1px solid #d1d5db;
  border-radius: 0 6px 6px 0;
  background: #e9ecf1;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  padding: 0;
  flex-shrink: 0;
}

.inbox-attachment-actions-btn:hover {
  background: #dde0e8;
  border-color: #b0b8c8;
  color: var(--ink);
}

/* Dropdown menu */
.inbox-attachment-actions-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 200;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
  min-width: 220px;
  padding: 4px;
}

.inbox-attachment-actions-menu.is-open {
  display: block;
}

.inbox-attachment-action-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
  transition: background 0.1s;
  white-space: nowrap;
}

.inbox-attachment-action-item:hover {
  background: var(--soft);
  color: var(--ink);
  text-decoration: none;
}

.inbox-attachment-action-item svg {
  flex-shrink: 0;
  color: var(--muted);
}

/* Import invoice modal body */
.import-invoice-modal-body {
  padding: 4px 0 0;
}

.import-invoice-modal-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 20px;
}

/* Compose box — Gorgias-style card */
.inbox-compose {
  flex-shrink: 0;
}

.inbox-compose--card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  padding: 20px 24px;
  margin: 0 24px 24px;
}

.inbox-compose-to {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.inbox-compose-to-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--muted);
}

.inbox-compose-to-label {
  font-weight: 500;
  color: var(--ink);
}

.inbox-compose-to-email {
  color: var(--ink);
}

.inbox-compose-type {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
}

.inbox-compose-type-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.inbox-compose-type-btn:first-child {
  border-radius: 8px 0 0 8px;
  border-right: none;
}

.inbox-compose-type-btn:last-child {
  border-radius: 0 8px 8px 0;
}

.inbox-compose-type-btn:hover {
  color: var(--ink);
  background: var(--soft);
}

.inbox-compose-type-btn.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.inbox-compose-type-btn.is-note.is-active {
  background: #92400e;
  border-color: #92400e;
}

.inbox-compose-macro-bar {
  position: relative;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.inbox-compose-macro-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.inbox-compose-macro-search:hover {
  border-color: var(--muted);
  background: var(--soft);
}

.inbox-compose-macro-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--muted);
}

.inbox-compose-suggested-wrap {
  margin-top: 10px;
  margin-bottom: 10px;
}

.inbox-compose-suggested-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 8px;
}

.inbox-compose-suggested-label svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.inbox-compose-suggested {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inbox-compose-suggested-pill {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 20px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.inbox-compose-suggested-pill:hover {
  background: var(--soft);
  border-color: var(--muted);
}

.inbox-compose-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.inbox-compose-send-group {
  display: flex;
  gap: 8px;
}

.inbox-compose-send-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  border: 1px solid transparent;
}

.inbox-compose-send-btn--primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.inbox-compose-send-btn--primary:hover {
  background: #374151;
  border-color: #374151;
}

.inbox-compose-send-btn--secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.inbox-compose-send-btn--secondary:hover {
  background: var(--soft);
  border-color: var(--muted);
}

.inbox-compose-send-btn--note {
  background: #fef9c3;
  color: #78350f;
  border-color: #fde68a;
}

.inbox-compose-send-btn--note:hover {
  background: #fef08a;
  border-color: #facc15;
}

.inbox-compose-macro-hint {
  font-size: 12px;
  color: var(--muted);
}

.inbox-compose-macro-hint kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 11px;
  font-family: inherit;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
}

/* Rich text (Trix) in compose — editor on top, toolbar at bottom, single bordered box */
.inbox-compose-rich-text {
  margin-bottom: 8px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
/* Rails outputs input + trix-editor; Trix injects trix-toolbar. Order so editor is first, toolbar second. */
.inbox-compose-rich-text trix-editor {
  order: 1;
  min-height: 170px;
  height: 170px;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 10px 12px;
  font-size: 15px;
  line-height: 1.5;
}
.inbox-compose-rich-text trix-toolbar {
  order: 2;
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  background: #fafafa;
  padding: 4px 8px 6px;
}
.inbox-compose-rich-text--note trix-editor {
  background: #fef9c3;
  border-color: #fde68a;
  border-bottom: none;
}
.inbox-compose-rich-text--note trix-toolbar {
  border-color: #fde68a;
  background: #fefce8;
}
.inbox-compose--standalone .inbox-compose-rich-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.inbox-compose--standalone .inbox-compose-rich-text trix-editor {
  min-height: 480px;
  height: auto;
  flex: 1;
  max-height: none;
}

/* Inbox Trix toolbar: same border as editor so it looks like one input box, below editor */
.inbox-compose trix-toolbar {
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  padding: 4px 8px 6px;
}
.inbox-compose trix-toolbar .trix-button-row {
  margin-bottom: 0;
  justify-content: flex-start;
}
.inbox-compose trix-toolbar .trix-button-group {
  border: none;
  border-radius: 4px;
  margin-bottom: 0;
  margin-left: 0;
  background: transparent;
  box-shadow: none;
}
.inbox-compose trix-toolbar .trix-button-group:not(:first-child) {
  margin-left: 2px;
}
.inbox-compose trix-toolbar .trix-button {
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 11px;
  transition: color 0.1s ease, background 0.1s ease;
}
.inbox-compose trix-toolbar .trix-button:not(:first-child) {
  border-left: none;
}
.inbox-compose trix-toolbar .trix-button:hover:not(:disabled) {
  color: var(--ink);
  background: var(--soft);
}
.inbox-compose trix-toolbar .trix-button.trix-active {
  color: var(--accent);
  background: var(--accent-weak);
}
.inbox-compose trix-toolbar .trix-button:disabled {
  color: var(--line);
  opacity: 0.5;
}
.inbox-compose trix-toolbar .trix-button--icon {
  width: 22px;
  height: 22px;
  max-width: 22px;
  min-width: 22px;
}
.inbox-compose trix-toolbar .trix-button--icon::before {
  opacity: 0.6;
  background-size: 14px 14px;
}
.inbox-compose trix-toolbar .trix-button--icon:hover:not(:disabled)::before,
.inbox-compose trix-toolbar .trix-button--icon.trix-active::before {
  opacity: 1;
}
.inbox-compose trix-toolbar .trix-button--icon:disabled::before {
  opacity: 0.3;
}

/* Trix content attachments (PO item tables) — render cleanly without default Trix attachment chrome */
.inbox-compose trix-editor figure[data-trix-attachment] {
  margin: 8px 0;
  padding: 0;
  max-width: 100%;
}
.inbox-compose trix-editor .attachment--content {
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  background: none !important;
}
.inbox-compose trix-editor .attachment__caption {
  display: none !important;
}
.inbox-compose trix-editor .attachment--content .attachment__content {
  max-width: 100%;
  overflow-x: auto;
}

/* New-message compose: fill the detail area, use full width (no thin column) */
.inbox-compose--standalone {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  padding: 24px 48px 32px;
  border-top: none;
  box-sizing: border-box;
}
.inbox-compose--standalone form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.inbox-compose--standalone form > div,
.inbox-compose--standalone .inbox-compose-toolbar {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.inbox-compose--standalone input.inbox-compose-editor,
.inbox-compose--standalone textarea.inbox-compose-editor {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.inbox-compose--standalone textarea.inbox-compose-editor {
  min-height: 240px;
  max-height: none;
  flex: 1;
}
.inbox-compose--standalone .inbox-compose-toolbar {
  margin-top: 12px;
  flex-shrink: 0;
}

.inbox-compose-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 8px;
}

.inbox-compose-toggle-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  background: none;
  border: 1px solid var(--line);
  cursor: pointer;
  color: var(--muted);
  transition: all 0.1s ease;
}

.inbox-compose-toggle-btn:first-child {
  border-radius: 6px 0 0 6px;
}

.inbox-compose-toggle-btn:last-child {
  border-radius: 0 6px 6px 0;
  border-left: none;
}

.inbox-compose-toggle-btn.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.inbox-compose-toggle-btn.is-note.is-active {
  background: #fef9c3;
  color: #78350f;
  border-color: #fde68a;
}

.inbox-compose-template-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  position: relative;
}

.inbox-compose-template-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
  background: var(--soft);
  cursor: pointer;
  transition: all 0.1s ease;
}

.inbox-compose-template-search:hover {
  border-color: var(--accent);
}

.inbox-compose-template-search svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.inbox-compose-editor {
  min-height: 80px;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background: #fff;
  outline: none;
  resize: none;
  width: 100%;
}

.inbox-compose-editor:focus {
  border-color: var(--accent);
}

.inbox-compose.is-note .inbox-compose-editor {
  background: #fef9c3;
  border-color: #fde68a;
}

.inbox-compose-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.inbox-compose-formatting {
  display: flex;
  gap: 2px;
}

.inbox-compose-fmt-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  border-radius: 4px;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: all 0.1s ease;
}

.inbox-compose-fmt-btn:hover {
  background: var(--soft);
  color: var(--ink);
}

.inbox-compose-fmt-btn svg {
  width: 14px;
  height: 14px;
}

.inbox-compose-send-group {
  display: flex;
  gap: 4px;
}

.inbox-compose-suggested {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.inbox-compose-suggested-pill {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--soft);
  color: var(--muted);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: all 0.1s ease;
}

.inbox-compose-suggested-pill:hover {
  background: var(--accent-weak);
  color: var(--accent);
  border-color: var(--accent);
}

/* Empty state for thread detail */
.inbox-detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
}

.inbox-detail-empty svg {
  width: 48px;
  height: 48px;
  stroke: var(--line);
}

/* ── Context right-sidebar (Column D) ────────────────────── */

.inbox-context-sidebar {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.inbox-context-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
}

/* Contact header */
.inbox-ctx-contact {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.inbox-ctx-contact-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.inbox-ctx-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.inbox-ctx-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.inbox-ctx-name a {
  color: var(--accent);
}

.inbox-ctx-name a:hover {
  text-decoration: underline;
}

.inbox-ctx-email {
  font-size: 12px;
  color: var(--muted);
}

.inbox-ctx-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  background: #dcfce7;
  color: #166534;
}

.inbox-ctx-badge--inactive {
  background: var(--soft);
  color: var(--muted);
}

.inbox-ctx-badge--prospect {
  background: #fef9c3;
  color: #78350f;
}

.inbox-ctx-badge--blocked {
  background: #fee2e2;
  color: #991b1b;
}

/* Quick actions */
.inbox-ctx-actions {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
}

.inbox-ctx-action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  transition: all 0.1s ease;
  text-decoration: none;
  text-align: center;
}

.inbox-ctx-action-btn:hover {
  background: var(--soft);
  color: var(--ink);
}

.inbox-ctx-action-btn svg {
  width: 16px;
  height: 16px;
}

/* Collapsible sections */
.inbox-ctx-section {
  border-bottom: 1px solid var(--line);
}

.inbox-ctx-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
}

.inbox-ctx-section-header:hover {
  background: var(--soft);
}

.inbox-ctx-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 0;
}

.inbox-ctx-section-toggle {
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.inbox-ctx-section.is-collapsed .inbox-ctx-section-toggle {
  transform: rotate(-90deg);
}

.inbox-ctx-section-body {
  padding: 0 16px 12px;
}

.inbox-ctx-section.is-collapsed .inbox-ctx-section-body {
  display: none;
}

/* Quick facts */
.inbox-ctx-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.inbox-ctx-fact {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.inbox-ctx-fact-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
}

.inbox-ctx-fact-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

/* PO / Invoice / Shipment list items */
.inbox-ctx-record {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--soft);
}

.inbox-ctx-record:last-child {
  border-bottom: none;
}

.inbox-ctx-record-left {
  min-width: 0;
}

.inbox-ctx-record-id {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
}

.inbox-ctx-record-id:hover {
  text-decoration: underline;
}

.inbox-ctx-record-detail {
  font-size: 11px;
  color: var(--muted);
}

.inbox-ctx-record-action {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--soft);
  border: 1px solid var(--line);
  cursor: pointer;
  color: var(--muted);
  white-space: nowrap;
}

.inbox-ctx-record-action:hover {
  background: var(--accent-weak);
  color: var(--accent);
}

/* Thread linking chip */
.inbox-ctx-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--accent-weak);
  color: var(--accent);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 6px;
}

.inbox-ctx-link-chip a {
  color: var(--accent);
  text-decoration: underline;
}

.inbox-ctx-link-chip .inbox-ctx-unlink {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  opacity: 0.6;
}

.inbox-ctx-link-chip .inbox-ctx-unlink:hover {
  opacity: 1;
}

/* Conversation summary */
.inbox-ctx-summary {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.inbox-ctx-summary a {
  color: var(--accent);
}

/* Internal notes section */
.inbox-ctx-notes-count {
  font-size: 12px;
  color: var(--muted);
}

/* Section footer links */
.inbox-ctx-section-footer {
  padding-top: 6px;
}

.inbox-ctx-section-footer a {
  font-size: 12px;
  color: var(--accent);
}

.inbox-ctx-section-footer a:hover {
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════
   Template picker modal (overlay in compose)
   ═══════════════════════════════════════════════════════════ */

.inbox-template-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  max-height: 280px;
  overflow-y: auto;
  z-index: 20;
  display: none;
}

.inbox-template-picker.is-open {
  display: block;
}

.inbox-template-picker-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}

.inbox-template-picker-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  width: 100%;
  color: var(--ink);
}

.inbox-template-picker-list {
  padding: 4px;
}

.inbox-template-picker-item {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s ease;
}

.inbox-template-picker-item:hover {
  background: var(--soft);
}

.inbox-template-picker-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

.inbox-template-picker-item-preview {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-template-picker-item-tags {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.inbox-template-picker-tag {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--soft);
  color: var(--muted);
}

/* ===== PO Line Item Picker Modal ===== */

.po-picker-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.35);
  align-items: center;
  justify-content: center;
}
.po-picker-overlay.is-open {
  display: flex;
}

.po-picker-modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  width: 1200px;
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.po-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line, #e5e7eb);
}

.po-picker-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--ink, #111827);
}

.po-picker-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--muted, #6b7280);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.po-picker-close:hover {
  color: var(--ink, #111827);
}

.po-picker-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.po-picker-sidebar {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid var(--line, #e5e7eb);
  overflow-y: auto;
  background: #f9fafb;
  padding: 8px 0;
}

.po-picker-po-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  border: none;
  background: none;
  padding: 10px 16px;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}
.po-picker-po-btn:hover {
  background: #f3f4f6;
}
.po-picker-po-btn.is-active {
  background: #eef2ff;
  border-right: 2px solid var(--primary, #4f46e5);
}

.po-picker-po-number {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink, #111827);
}

.po-picker-po-meta {
  font-size: 11px;
  color: var(--muted, #6b7280);
  margin-top: 2px;
}

.po-picker-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Detail (PO selected): flex column so line items area can scroll */
.po-picker-detail {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.po-picker-loading {
  padding: 32px;
  text-align: center;
  color: var(--muted, #6b7280);
  font-size: 13px;
}

.po-picker-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #e5e7eb;
  border-top-color: var(--primary, #4f46e5);
  border-radius: 50%;
  animation: po-picker-spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes po-picker-spin {
  to { transform: rotate(360deg); }
}

.po-picker-columns-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line, #e5e7eb);
  background: #fafbfc;
  flex-wrap: wrap;
}

.po-picker-columns-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, #6b7280);
  white-space: nowrap;
}

.po-picker-col-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  color: var(--ink, #111827);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.1s;
  white-space: nowrap;
  user-select: none;
}
.po-picker-col-toggle:hover {
  background: #f3f4f6;
}
.po-picker-col-toggle input {
  margin: 0;
  accent-color: var(--primary, #4f46e5);
}

.po-picker-items-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0;
}

.po-picker-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.po-picker-th {
  padding: 8px 10px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted, #6b7280);
  border-bottom: 1px solid var(--line, #e5e7eb);
  background: #fafbfc;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 1;
}
.po-picker-th--check {
  width: 36px;
  text-align: center;
}
.po-picker-th--num {
  text-align: right;
}

.po-picker-row {
  cursor: pointer;
  transition: background 0.1s;
}
.po-picker-row:hover {
  background: #f9fafb;
}

.po-picker-cell {
  padding: 8px 10px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
  color: var(--ink, #111827);
}
.po-picker-cell--check {
  text-align: center;
}
.po-picker-cell--check input {
  margin: 0;
  accent-color: var(--primary, #4f46e5);
}
.po-picker-cell--img {
  width: 44px;
}
.po-picker-cell--sku {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: var(--muted, #6b7280);
}
.po-picker-cell--product {
  max-width: 200px;
}
.po-picker-cell--num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.po-picker-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
}

.po-picker-no-img {
  display: inline-block;
  width: 36px;
  height: 36px;
  border-radius: 4px;
  background: #f3f4f6;
  text-align: center;
  line-height: 36px;
  color: #d1d5db;
  font-size: 16px;
}

.po-picker-variant-name {
  font-size: 11px;
  color: var(--muted, #6b7280);
  margin-top: 1px;
}

.po-picker-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted, #6b7280);
  font-size: 13px;
}

.po-picker-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--line, #e5e7eb);
  background: #fafbfc;
}

.po-picker-footer .btn {
  font-size: 13px;
  padding: 7px 16px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
}
.po-picker-footer .btn-light {
  background: #f3f4f6;
  color: var(--ink, #111827);
}
.po-picker-footer .btn-light:hover {
  background: #e5e7eb;
}
.po-picker-footer .btn-primary {
  background: var(--primary, #4f46e5);
  color: #fff;
}
.po-picker-footer .btn-primary:hover:not(:disabled) {
  opacity: 0.9;
}
.po-picker-footer .btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ============================================================
   MOBILE RESPONSIVE — Inbox Layout
   ============================================================ */

/* Mobile back button (hidden on desktop) */
.inbox-mobile-back-btn {
  display: none;
}

/* ── At 1024px: hide context sidebar to give more room ── */
@media (max-width: 1024px) {
  .inbox-shell {
    grid-template-columns: 220px 320px 1fr;
  }
  .inbox-shell > .inbox-context-sidebar {
    display: none;
  }
}

/* ── At 768px: single column stack ── */
@media (max-width: 768px) {
  /* Hide the app rail (App/Inbox icons) on mobile */
  .app-rail {
    display: none !important;
  }

  /* When the rail is hidden, remove its desktop offset from the app shell */
  .super-shell .app-shell {
    margin-left: 0;
  }

  /* Remove dark gutter background on mobile */
  body.pp-body-inbox {
    background: #f6f7f9;
    padding: 0;
  }

  /* Re-anchor header and sidebar to left: 0 when app rail is hidden */
  .super-shell .header-bar {
    left: 0;
  }
  .super-shell .sidebar {
    left: 0;
  }
  .super-shell .sidebar-corner,
  .super-shell .sidebar-hover-zone {
    display: none !important;
  }
  /* Inbox page shell takes full height */
  .inbox-page-shell {
    flex-direction: column;
    overflow: hidden;
    margin-left: 0;
    border-radius: 0;
  }
  .pp-body-inbox .inbox-page-shell .main {
    border-radius: 0;
  }

  /* Single-column layout: show thread list by default */
  .inbox-shell {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);
    overflow: hidden;
    margin-left: 0;
  }

  /* Hide filter sidebar on mobile (accessible via scroll/nav) */
  .inbox-shell > .inbox-filter-sidebar {
    display: none;
  }

  /* Thread list: full height when no detail open */
  .inbox-shell > .inbox-thread-list {
    flex: 1;
    min-height: 0;
  }

  /* Thread detail: hidden by default, shown when a thread is selected */
  .inbox-shell > .inbox-thread-detail {
    display: none;
  }
  .inbox-shell > .inbox-context-sidebar {
    display: none;
  }

  /* When a thread is open: hide thread list, show detail full-screen */
  .inbox-shell.has-detail > .inbox-thread-list {
    display: none;
  }
  .inbox-shell.has-detail > .inbox-thread-detail {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  /* Composing mode: full width */
  .inbox-shell.is-composing {
    grid-template-columns: 1fr;
  }

  /* Show back button on mobile */
  .inbox-mobile-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    padding: 4px 0;
    margin-bottom: 4px;
    text-decoration: none;
  }
  .inbox-mobile-back-btn svg {
    width: 16px;
    height: 16px;
  }
  .inbox-mobile-back-btn:hover {
    opacity: 0.8;
  }

  /* Inbox detail header: stack vertically */
  .inbox-detail-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 16px;
  }
  .inbox-detail-header-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    width: 100%;
  }
  .inbox-detail-subject {
    font-size: 15px;
  }
  .inbox-detail-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Compose footer: stack buttons */
  .inbox-compose-footer {
    flex-direction: column;
    gap: 8px;
  }
  .inbox-compose-send-group {
    flex-wrap: wrap;
    gap: 6px;
  }
  .inbox-compose-macro-hint {
    display: none;
  }
}
