/* ==========================================================================
   CYBORG OPERATIONAL INBOX & WORKSTATION (GMAIL FIDELITY)
   ========================================================================== */

/* ── Light Theme Tokens (Default) ── */
:root,
body,
body.theme-light {
  --ib-app-bg: #f8fafc;
  --ib-topbar-bg: #ffffff;
  --ib-topbar-border: #e2e8f0;

  --ib-brand-title: #0284c7;
  --ib-brand-badge-bg: #e0f2fe;
  --ib-brand-badge-color: #0369a1;
  --ib-brand-badge-border: #bae6fd;

  --ib-search-bg: #f8fafc;
  --ib-search-border: #cbd5e1;
  --ib-search-text: #0f172a;
  --ib-search-placeholder: #94a3b8;
  --ib-search-focus-bg: #ffffff;
  --ib-search-focus-border: #0284c7;
  --ib-search-focus-ring: rgba(2, 132, 199, 0.15);

  --ib-btn-bg: #ffffff;
  --ib-btn-border: #e2e8f0;
  --ib-btn-color: #475569;
  --ib-btn-hover-bg: #f1f5f9;
  --ib-btn-hover-border: #cbd5e1;
  --ib-btn-hover-color: #0f172a;

  --ib-view-switch-bg: #f0f9ff;
  --ib-view-switch-border: #bae6fd;
  --ib-view-switch-color: #0284c7;
  --ib-view-switch-hover-bg: #e0f2fe;
  --ib-view-switch-hover-color: #0369a1;

  --ib-toolbar-bg: #ffffff;
  --ib-toolbar-border: #e2e8f0;

  --ib-tab-color: #64748b;
  --ib-tab-hover-color: #0f172a;
  --ib-tab-hover-bg: #f1f5f9;
  --ib-tab-active-color: #0284c7;
  --ib-tab-active-border: #0284c7;
  --ib-tab-active-bg: #f0f9ff;
  --ib-tab-badge-bg: #0284c7;
  --ib-tab-badge-color: #ffffff;

  --ib-pill-bg: #f8fafc;
  --ib-pill-border: #e2e8f0;
  --ib-pill-color: #475569;
  --ib-pill-hover-bg: #f1f5f9;
  --ib-pill-hover-border: #cbd5e1;
  --ib-pill-hover-color: #0f172a;
  --ib-pill-active-bg: #0284c7;
  --ib-pill-active-border: #0284c7;
  --ib-pill-active-color: #ffffff;

  --ib-subbar-bg: #f8fafc;
  --ib-subbar-border: #e2e8f0;
  --ib-subbar-color: #64748b;
  --ib-subbar-btn-hover-bg: #e2e8f0;
  --ib-subbar-btn-hover-color: #0f172a;

  --ib-list-bg: #f8fafc;
  --ib-row-bg: #ffffff;
  --ib-row-border: #f1f5f9;
  --ib-row-hover-bg: #f8fafc;
  
  --ib-row-unread-bg: #f0f7ff;
  --ib-row-unread-border: #e2e8f0;
  --ib-row-unread-accent: #0284c7;

  --ib-text-primary: #0f172a;
  --ib-text-secondary: #334155;
  --ib-text-muted: #64748b;
  --ib-text-dim: #94a3b8;

  --ib-row-senders-color: #334155;
  --ib-row-subject-color: #334155;
  --ib-row-dash-color: #cbd5e1;
  --ib-row-snippet-color: #64748b;
  --ib-row-date-color: #64748b;

  --ib-search-highlight-bg: #fef08a;
  --ib-search-highlight-color: #854d0e;
  --ib-search-highlight-border: rgba(202, 138, 4, 0.3);

  --ib-star-color: #cbd5e1;
  --ib-star-hover: #eab308;
  --ib-star-active: #eab308;

  --ib-cyborg-badge-bg: #f1f5f9;
  --ib-cyborg-badge-color: #475569;
  --ib-cyborg-badge-border: #e2e8f0;

  --ib-cat-po-bg: #ecfdf5;
  --ib-cat-po-color: #047857;
  --ib-cat-po-border: #a7f3d0;
  --ib-cat-rfq-bg: #fefce8;
  --ib-cat-rfq-color: #a16207;
  --ib-cat-rfq-border: #fef08a;
  --ib-cat-shipping-bg: #eff6ff;
  --ib-cat-shipping-color: #1d4ed8;
  --ib-cat-shipping-border: #bfdbfe;
  --ib-cat-vendor-bg: #faf5ff;
  --ib-cat-vendor-color: #7e22ce;
  --ib-cat-vendor-border: #e9d5ff;

  --ib-att-bg: #f8fafc;
  --ib-att-border: #e2e8f0;
  --ib-att-color: #475569;
  --ib-att-hover-bg: #f1f5f9;
  --ib-att-hover-border: #0284c7;
  --ib-att-hover-color: #0284c7;

  --ib-empty-color: #64748b;
  --ib-spinner-border: rgba(2, 132, 199, 0.15);
  --ib-spinner-active: #0284c7;

  --ib-scrollbar-thumb: #cbd5e1;
  --ib-scrollbar-thumb-hover: #94a3b8;
  --ib-scrollbar-track: transparent;

  /* Mobile tabs */
  --ib-mobile-tabs-bg: #f1f5f9;
  --ib-mobile-tab-active-bg: #ffffff;
  --ib-mobile-tab-active-color: #0284c7;
  --ib-mobile-tab-active-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);

  /* Modal */
  --ib-modal-bg: #ffffff;
  --ib-modal-header-bg: #f8fafc;
  --ib-modal-border: #e2e8f0;
  --ib-modal-text: #0f172a;
  --ib-modal-backdrop: rgba(15, 23, 42, 0.45);
  --ib-modal-btn-download-bg: #0284c7;
  --ib-modal-btn-download-color: #ffffff;

  /* Shadow DOM Email typography */
  --email-text-color: #202124;
  --email-link-color: #1a73e8;
  --email-quote-border: #dadce0;
  --email-quote-color: #5f6368;
  --email-quote-dots-bg: #f1f3f4;
  --email-quote-dots-border: #dadce0;
  --email-quote-dots-color: #5f6368;
  --email-quote-dots-hover-bg: #e8eaed;
  --email-quote-dots-hover-color: #202124;
  --email-quote-dots-hover-border: #bdc1c6;
  --email-quote-dots-active-bg: #e8f0fe;
  --email-quote-dots-active-border: #1a73e8;
  --email-quote-dots-active-color: #1a73e8;
}

/* ── Dark Theme Tokens (User Toggleable) ── */
[data-theme="dark"],
body.theme-dark {
  --ib-app-bg: #090d16;
  --ib-topbar-bg: #0f1523;
  --ib-topbar-border: #1e293b;

  --ib-brand-title: #38bdf8;
  --ib-brand-badge-bg: rgba(56, 189, 248, 0.15);
  --ib-brand-badge-color: #38bdf8;
  --ib-brand-badge-border: transparent;

  --ib-search-bg: #182235;
  --ib-search-border: #283548;
  --ib-search-text: #e2e8f0;
  --ib-search-placeholder: #64748b;
  --ib-search-focus-bg: #1b263b;
  --ib-search-focus-border: #38bdf8;
  --ib-search-focus-ring: rgba(56, 189, 248, 0.2);

  --ib-btn-bg: #131b2e;
  --ib-btn-border: #1e293b;
  --ib-btn-color: #94a3b8;
  --ib-btn-hover-bg: #1e293b;
  --ib-btn-hover-border: #334155;
  --ib-btn-hover-color: #e2e8f0;

  --ib-view-switch-bg: rgba(56, 189, 248, 0.1);
  --ib-view-switch-border: rgba(56, 189, 248, 0.3);
  --ib-view-switch-color: #38bdf8;
  --ib-view-switch-hover-bg: rgba(56, 189, 248, 0.2);
  --ib-view-switch-hover-color: #bae6fd;

  --ib-toolbar-bg: #0f1523;
  --ib-toolbar-border: #1e293b;

  --ib-tab-color: #94a3b8;
  --ib-tab-hover-color: #e2e8f0;
  --ib-tab-hover-bg: rgba(255, 255, 255, 0.04);
  --ib-tab-active-color: #38bdf8;
  --ib-tab-active-border: #38bdf8;
  --ib-tab-active-bg: rgba(56, 189, 248, 0.08);
  --ib-tab-badge-bg: #38bdf8;
  --ib-tab-badge-color: #090d16;

  --ib-pill-bg: #131b2e;
  --ib-pill-border: #1e293b;
  --ib-pill-color: #94a3b8;
  --ib-pill-hover-bg: #1e293b;
  --ib-pill-hover-border: #1e293b;
  --ib-pill-hover-color: #e2e8f0;
  --ib-pill-active-bg: #38bdf8;
  --ib-pill-active-border: #38bdf8;
  --ib-pill-active-color: #090d16;

  --ib-subbar-bg: #0f1523;
  --ib-subbar-border: #1e293b;
  --ib-subbar-color: #94a3b8;
  --ib-subbar-btn-hover-bg: rgba(255, 255, 255, 0.08);
  --ib-subbar-btn-hover-color: #e2e8f0;

  --ib-list-bg: #0c111d;
  --ib-row-bg: #0d1322;
  --ib-row-border: #182235;
  --ib-row-hover-bg: #131b2e;
  
  --ib-row-unread-bg: #101728;
  --ib-row-unread-border: #182235;
  --ib-row-unread-accent: #38bdf8;

  --ib-text-primary: #f8fafc;
  --ib-text-secondary: #e2e8f0;
  --ib-text-muted: #94a3b8;
  --ib-text-dim: #64748b;

  --ib-row-senders-color: #cbd5e1;
  --ib-row-subject-color: #e2e8f0;
  --ib-row-dash-color: #475569;
  --ib-row-snippet-color: #94a3b8;
  --ib-row-date-color: #64748b;

  --ib-search-highlight-bg: rgba(234, 179, 8, 0.28);
  --ib-search-highlight-color: #fef08a;
  --ib-search-highlight-border: rgba(250, 204, 21, 0.35);

  --ib-star-color: #64748b;
  --ib-star-hover: #facc15;
  --ib-star-active: #facc15;

  --ib-cyborg-badge-bg: rgba(148, 163, 184, 0.15);
  --ib-cyborg-badge-color: #cbd5e1;
  --ib-cyborg-badge-border: rgba(148, 163, 184, 0.25);

  --ib-cat-po-bg: rgba(74, 222, 128, 0.15);
  --ib-cat-po-color: #4ade80;
  --ib-cat-po-border: rgba(74, 222, 128, 0.25);
  --ib-cat-rfq-bg: rgba(250, 204, 21, 0.15);
  --ib-cat-rfq-color: #facc15;
  --ib-cat-rfq-border: rgba(250, 204, 21, 0.25);
  --ib-cat-shipping-bg: rgba(96, 165, 250, 0.15);
  --ib-cat-shipping-color: #60a5fa;
  --ib-cat-shipping-border: rgba(96, 165, 250, 0.25);
  --ib-cat-vendor-bg: rgba(232, 121, 249, 0.15);
  --ib-cat-vendor-color: #e879f9;
  --ib-cat-vendor-border: rgba(232, 121, 249, 0.25);

  --ib-att-bg: #182235;
  --ib-att-border: #283548;
  --ib-att-color: #cbd5e1;
  --ib-att-hover-bg: #233149;
  --ib-att-hover-border: #38bdf8;
  --ib-att-hover-color: #38bdf8;

  --ib-empty-color: #64748b;
  --ib-spinner-border: rgba(56, 189, 248, 0.15);
  --ib-spinner-active: #38bdf8;

  --ib-scrollbar-thumb: #1e293b;
  --ib-scrollbar-thumb-hover: #334155;
  --ib-scrollbar-track: transparent;

  /* Mobile tabs */
  --ib-mobile-tabs-bg: #131b2e;
  --ib-mobile-tab-active-bg: #1e293b;
  --ib-mobile-tab-active-color: #38bdf8;
  --ib-mobile-tab-active-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);

  /* Modal */
  --ib-modal-bg: #0f1523;
  --ib-modal-header-bg: #131b2e;
  --ib-modal-border: #1e293b;
  --ib-modal-text: #f1f5f9;
  --ib-modal-backdrop: rgba(0, 0, 0, 0.75);
  --ib-modal-btn-download-bg: #38bdf8;
  --ib-modal-btn-download-color: #090d16;

  /* Shadow DOM Email typography */
  --email-text-color: #e2e8f0;
  --email-link-color: #38bdf8;
  --email-quote-border: #334155;
  --email-quote-color: #94a3b8;
  --email-quote-dots-bg: #1e293b;
  --email-quote-dots-border: #334155;
  --email-quote-dots-color: #94a3b8;
  --email-quote-dots-hover-bg: #334155;
  --email-quote-dots-hover-color: #f8fafc;
  --email-quote-dots-hover-border: #475569;
  --email-quote-dots-active-bg: rgba(56, 189, 248, 0.15);
  --email-quote-dots-active-border: #38bdf8;
  --email-quote-dots-active-color: #38bdf8;
}

/* ── Global App Topbar ── */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  min-height: 56px;
  padding: 0 16px;
  background: var(--ib-topbar-bg, #ffffff);
  border-bottom: 1px solid var(--ib-topbar-border, #e2e8f0);
  position: relative;
  z-index: 50;
  gap: 16px;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  transition: filter 0.2s ease;
}

body.theme-light .brand-logo {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

.brand-text-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-title {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--ib-brand-title, #0284c7);
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--ib-brand-badge-bg, #e0f2fe);
  color: var(--ib-brand-badge-color, #0369a1);
  border: 1px solid var(--ib-brand-badge-border, #bae6fd);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.08em;
}

/* Center Search Bar */
.topbar-search-wrapper {
  flex: 1;
  max-width: 680px;
  position: relative;
}

.search-input-box {
  display: flex;
  align-items: center;
  background: var(--ib-search-bg, #f8fafc);
  border: 1px solid var(--ib-search-border, #cbd5e1);
  border-radius: 8px;
  padding: 5px 10px;
  gap: 8px;
  transition: all 0.2s ease;
}

.search-input-box:focus-within {
  background: var(--ib-search-focus-bg, #ffffff);
  border-color: var(--ib-search-focus-border, #0284c7);
  box-shadow: 0 0 0 2px var(--ib-search-focus-ring, rgba(2, 132, 199, 0.15));
}

.search-submit-btn {
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  font-size: 0.88rem;
  opacity: 0.75;
  color: var(--ib-text-muted, #64748b);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.15s ease;
  user-select: none;
}

.search-submit-btn:hover {
  opacity: 1;
  transform: scale(1.08);
  color: var(--ib-brand-title, #0284c7);
}

.search-icon {
  font-size: 0.85rem;
  opacity: 0.7;
  color: var(--ib-text-muted, #64748b);
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--ib-search-text, #0f172a);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  outline: none;
  min-width: 0;
}

.search-input::placeholder {
  color: var(--ib-search-placeholder, #94a3b8);
}

.search-clear-btn {
  background: none;
  border: none;
  color: var(--ib-text-muted, #94a3b8);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.search-clear-btn:hover {
  color: var(--ib-text-primary, #0f172a);
  background: rgba(0, 0, 0, 0.05);
}

body.theme-dark .search-clear-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.search-filter-btn {
  background: none;
  border: none;
  color: var(--ib-text-muted, #64748b);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.search-filter-btn:hover,
.search-filter-btn.active {
  color: var(--ib-brand-title, #0284c7);
  background: rgba(2, 132, 199, 0.1);
}

.search-filter-svg {
  width: 15px;
  height: 15px;
  display: block;
}

/* ── Advanced Gmail Search Filter Dropdown ── */
.search-filter-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--ib-modal-bg, #ffffff);
  border: 1px solid var(--ib-modal-border, #cbd5e1);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
  z-index: 1000;
  overflow: hidden;
  animation: searchDropdownFadeIn 0.15s ease-out;
}

@keyframes searchDropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--ib-modal-header-bg, #f8fafc);
  border-bottom: 1px solid var(--ib-modal-border, #e2e8f0);
}

.search-filter-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ib-text-primary, #0f172a);
  letter-spacing: 0.02em;
}

.search-filter-close-btn {
  background: none;
  border: none;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--ib-text-muted, #64748b);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.search-filter-close-btn:hover {
  color: var(--ib-text-primary, #0f172a);
  background: rgba(0, 0, 0, 0.05);
}

.search-filter-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-filter-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 12px;
}

.search-filter-row label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ib-text-secondary, #475569);
  text-align: right;
  user-select: none;
}

.search-filter-input,
.search-filter-select {
  background: var(--ib-search-bg, #f8fafc);
  border: 1px solid var(--ib-search-border, #cbd5e1);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.84rem;
  color: var(--ib-text-primary, #0f172a);
  outline: none;
  font-family: var(--font-sans);
  transition: all 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.search-filter-input:focus,
.search-filter-select:focus {
  background: var(--ib-search-focus-bg, #ffffff);
  border-color: var(--ib-search-focus-border, #0284c7);
  box-shadow: 0 0 0 2px var(--ib-search-focus-ring, rgba(2, 132, 199, 0.15));
}

.search-filter-checkbox-row {
  grid-template-columns: 1fr;
  padding-left: 122px;
}

.search-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.8rem !important;
  color: var(--ib-text-secondary, #475569) !important;
  text-align: left !important;
  user-select: none;
}

.search-checkbox-label input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--ib-brand-title, #0284c7);
}

.search-filter-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 16px;
  background: var(--ib-modal-header-bg, #f8fafc);
  border-top: 1px solid var(--ib-modal-border, #e2e8f0);
}

.search-filter-reset-btn {
  background: transparent;
  border: 1px solid var(--ib-btn-border, #e2e8f0);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ib-text-muted, #64748b);
  cursor: pointer;
  transition: all 0.15s ease;
}

.search-filter-reset-btn:hover {
  color: var(--ib-text-primary, #0f172a);
  background: var(--ib-btn-hover-bg, #f1f5f9);
}

.search-filter-apply-btn {
  background: var(--ib-brand-title, #0284c7);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.15s ease;
}

.search-filter-apply-btn:hover {
  background: #0369a1;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.35);
}

/* ── Inbox Search Results Banner ── */
.inbox-search-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #e0f2fe;
  border-bottom: 1px solid #bae6fd;
  color: #0369a1;
  font-size: 0.84rem;
  font-weight: 500;
  animation: searchBannerSlideDown 0.2s ease-out;
}

body.theme-dark .inbox-search-banner {
  background: rgba(56, 189, 248, 0.12);
  border-bottom: 1px solid rgba(56, 189, 248, 0.25);
  color: #38bdf8;
}

@keyframes searchBannerSlideDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-banner-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.search-banner-icon {
  font-size: 0.95rem;
  flex-shrink: 0;
}

.search-banner-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-banner-text strong {
  font-weight: 600;
}

.search-banner-clear-btn {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.search-banner-clear-btn:hover {
  background: rgba(3, 105, 161, 0.12);
}

body.theme-dark .search-banner-clear-btn:hover {
  background: rgba(56, 189, 248, 0.2);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ib-btn-bg, #ffffff);
  border: 1px solid var(--ib-btn-border, #e2e8f0);
  color: var(--ib-btn-color, #475569);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.topbar-action-btn:hover {
  background: var(--ib-btn-hover-bg, #f1f5f9);
  color: var(--ib-btn-hover-color, #0f172a);
  border-color: var(--ib-btn-hover-border, #cbd5e1);
}

.topbar-action-btn .btn-icon.spinning {
  animation: spin 1s linear infinite;
}

.theme-toggle-btn {
  position: relative;
}

.theme-toggle-btn .btn-icon {
  font-size: 0.92rem;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle-btn:hover .btn-icon {
  transform: rotate(20deg) scale(1.15);
}

.theme-toggle-btn:active .btn-icon {
  transform: scale(0.92);
}

.google-auth-btn.connected {
  border-color: rgba(74, 222, 128, 0.3);
  color: #4ade80;
  background: rgba(74, 222, 128, 0.1);
}

body.theme-light .google-auth-btn.connected {
  border-color: #86efac;
  color: #166534;
  background: #f0fdf4;
}

.view-switch-btn {
  background: var(--ib-view-switch-bg, #f0f9ff);
  border-color: var(--ib-view-switch-border, #bae6fd);
  color: var(--ib-view-switch-color, #0284c7);
}

.view-switch-btn:hover {
  background: var(--ib-view-switch-hover-bg, #e0f2fe);
  color: var(--ib-view-switch-hover-color, #0369a1);
}

/* ── App Container ── */
.app-container {
  display: flex;
  flex-direction: row;
  height: calc(100vh - 56px);
  width: 100%;
  overflow: hidden;
  position: relative;
  background: var(--ib-app-bg, #f8fafc);
  transition: background-color 0.2s ease;
}

/* ── View 1: Inbox View ── */
.inbox-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  background: var(--ib-list-bg, #f8fafc);
}

.inbox-toolbar-panel {
  display: flex;
  flex-direction: column;
  padding: 10px 16px 8px 16px;
  background: var(--ib-toolbar-bg, #ffffff);
  border-bottom: 1px solid var(--ib-toolbar-border, #e2e8f0);
  gap: 10px;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.inbox-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inbox-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ib-tab-color, #64748b);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 4px 4px 0 0;
}

.inbox-tab:hover {
  color: var(--ib-tab-hover-color, #0f172a);
  background: var(--ib-tab-hover-bg, #f1f5f9);
}

.inbox-tab.active {
  color: var(--ib-tab-active-color, #0284c7);
  border-bottom-color: var(--ib-tab-active-border, #0284c7);
  background: var(--ib-tab-active-bg, #f0f9ff);
}

.inbox-tab .tab-badge {
  background: var(--ib-tab-badge-bg, #0284c7);
  color: var(--ib-tab-badge-color, #ffffff);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

.inbox-tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ── Dev-Mode "My Queue" Simulator Pill ── */
.dev-queue-sim {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--ib-dev-sim-bg, rgba(99, 102, 241, 0.08));
  border: 1px solid var(--ib-dev-sim-border, rgba(99, 102, 241, 0.25));
  border-radius: 20px;
  padding: 3px 8px 3px 6px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

.dev-queue-sim.simulating {
  background: var(--ib-dev-sim-active-bg, rgba(234, 88, 12, 0.1));
  border-color: var(--ib-dev-sim-active-border, rgba(234, 88, 12, 0.4));
  box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.15);
}

.dev-queue-sim .sim-badge-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dev-queue-sim .sim-badge {
  background: #6366f1;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 2px 5px;
  border-radius: 4px;
  text-transform: uppercase;
}

.dev-queue-sim.simulating .sim-badge {
  background: #ea580c;
}

.dev-queue-sim .sim-title {
  color: var(--ib-dev-sim-text, #475569);
  font-weight: 600;
  font-size: 0.76rem;
  white-space: nowrap;
}

.dev-queue-sim .sim-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.dev-queue-sim .sim-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--ib-dev-sim-select-bg, #ffffff);
  color: var(--ib-dev-sim-select-color, #1e293b);
  border: 1px solid var(--ib-dev-sim-select-border, #cbd5e1);
  border-radius: 12px;
  padding: 3px 22px 3px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 11px;
  transition: all 0.15s ease;
  max-width: 220px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.dev-queue-sim .sim-select:focus {
  border-color: #6366f1;
}

.dev-queue-sim.simulating .sim-select {
  border-color: #f97316;
  color: #c2410c;
}

.dev-queue-sim .sim-clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--ib-dev-sim-clear-bg, #e2e8f0);
  color: var(--ib-dev-sim-clear-color, #475569);
  font-size: 0.68rem;
  font-weight: bold;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: all 0.15s ease;
}

.dev-queue-sim .sim-clear-btn:hover {
  background: #f87171;
  color: #ffffff;
}

/* Tab indicator when simulating */
.tab-sim-indicator {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  color: #ea580c;
  background: rgba(234, 88, 12, 0.12);
  border: 1px solid rgba(234, 88, 12, 0.3);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
  font-weight: 600;
}

/* Dark mode overrides for Dev Simulator */
body.theme-dark .dev-queue-sim {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.35);
}
body.theme-dark .dev-queue-sim.simulating {
  background: rgba(234, 88, 12, 0.2);
  border-color: rgba(234, 88, 12, 0.5);
  box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.25);
}
body.theme-dark .dev-queue-sim .sim-title {
  color: #cbd5e1;
}
body.theme-dark .dev-queue-sim .sim-select {
  background: #1e293b;
  color: #e2e8f0;
  border-color: #475569;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}
body.theme-dark .dev-queue-sim.simulating .sim-select {
  border-color: #f97316;
  color: #fdba74;
}
body.theme-dark .dev-queue-sim .sim-clear-btn {
  background: #334155;
  color: #cbd5e1;
}
body.theme-dark .dev-queue-sim .sim-clear-btn:hover {
  background: #ef4444;
  color: #ffffff;
}
body.theme-dark .tab-sim-indicator {
  color: #fdba74;
  background: rgba(234, 88, 12, 0.25);
  border-color: rgba(234, 88, 12, 0.5);
}

.inbox-category-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.category-pill {
  background: var(--ib-pill-bg, #f8fafc);
  border: 1px solid var(--ib-pill-border, #e2e8f0);
  color: var(--ib-pill-color, #475569);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.category-pill:hover {
  background: var(--ib-pill-hover-bg, #f1f5f9);
  color: var(--ib-pill-hover-color, #0f172a);
  border-color: var(--ib-pill-hover-border, #cbd5e1);
}

.category-pill.active {
  background: var(--ib-pill-active-bg, #0284c7);
  color: var(--ib-pill-active-color, #ffffff);
  border-color: var(--ib-pill-active-border, #0284c7);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(2, 132, 199, 0.25);
}

/* Action Subbar */
.inbox-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: var(--ib-subbar-bg, #f8fafc);
  border-bottom: 1px solid var(--ib-subbar-border, #e2e8f0);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--ib-subbar-color, #64748b);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.subbar-left,
.subbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.inbox-checkbox-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.inbox-checkbox-label input {
  cursor: pointer;
  accent-color: var(--ib-tab-active-color, #0284c7);
  width: 15px;
  height: 15px;
}

.subbar-icon-btn,
.page-nav-btn {
  background: transparent;
  border: none;
  color: var(--ib-subbar-color, #64748b);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 4px 6px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.subbar-icon-btn:hover,
.page-nav-btn:not(:disabled):hover {
  background: var(--ib-subbar-btn-hover-bg, #e2e8f0);
  color: var(--ib-subbar-btn-hover-color, #0f172a);
}

.page-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── High Density Email List Rows (Gmail Parity) ── */
.inbox-list-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  background: var(--ib-list-bg, #f8fafc);
  transition: background-color 0.2s ease;
}

.inbox-rows-table {
  display: flex;
  flex-direction: column;
}

.inbox-row {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--ib-row-border, #f1f5f9);
  background: var(--ib-row-bg, #ffffff);
  cursor: pointer;
  transition: background-color 0.1s ease, border-color 0.1s ease;
  font-family: var(--font-sans);
  position: relative;
  gap: 12px;
}

.inbox-row:hover {
  background: var(--ib-row-hover-bg, #f8fafc);
}

.inbox-row.unread {
  background: var(--ib-row-unread-bg, #f0f7ff);
  border-bottom-color: var(--ib-row-unread-border, #e2e8f0);
}

.inbox-row.unread .row-subject {
  font-weight: 700;
  color: var(--ib-text-primary, #0f172a);
}

.inbox-row.unread .row-senders-text {
  font-weight: 700;
  color: var(--ib-text-primary, #0f172a);
}

.row-select {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.row-select input[type="checkbox"] {
  accent-color: var(--ib-tab-active-color, #0284c7);
  cursor: pointer;
  width: 14px;
  height: 14px;
}

.star-btn {
  background: none;
  border: none;
  color: var(--ib-star-color, #cbd5e1);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
  transition: color 0.15s ease;
}

.star-btn:hover {
  color: var(--ib-star-hover, #eab308);
}

.star-btn.starred {
  color: var(--ib-star-active, #eab308);
}

/* Senders Column */
.row-senders {
  width: 190px;
  min-width: 190px;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  color: var(--ib-row-senders-color, #334155);
  flex-shrink: 0;
}

.row-senders-count {
  font-size: 0.78rem;
  color: var(--ib-text-muted, #64748b);
  margin-left: 4px;
  font-weight: 400;
}

/* Cyborg Pill Badge (from user screenshot) */
.row-badge-cyborg {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 12px;
  background: var(--ib-cyborg-badge-bg, #f1f5f9);
  color: var(--ib-cyborg-badge-color, #475569);
  border: 1px solid var(--ib-cyborg-badge-border, #e2e8f0);
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

/* Category Badge */
.row-badge-cat {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
  white-space: nowrap;
}

.row-badge-cat.po {
  background: var(--ib-cat-po-bg, #ecfdf5);
  color: var(--ib-cat-po-color, #047857);
  border: 1px solid var(--ib-cat-po-border, #a7f3d0);
}

.row-badge-cat.rfq {
  background: var(--ib-cat-rfq-bg, #fefce8);
  color: var(--ib-cat-rfq-color, #a16207);
  border: 1px solid var(--ib-cat-rfq-border, #fef08a);
}

.row-badge-cat.shipping {
  background: var(--ib-cat-shipping-bg, #eff6ff);
  color: var(--ib-cat-shipping-color, #1d4ed8);
  border: 1px solid var(--ib-cat-shipping-border, #bfdbfe);
}

.row-badge-cat.vendor {
  background: var(--ib-cat-vendor-bg, #faf5ff);
  color: var(--ib-cat-vendor-color, #7e22ce);
  border: 1px solid var(--ib-cat-vendor-border, #e9d5ff);
}

/* Content (Subject + Snippet) */
.row-content {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  font-size: 0.88rem;
}

.row-subject {
  color: var(--ib-row-subject-color, #334155);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-dash {
  color: var(--ib-row-dash-color, #cbd5e1);
  flex-shrink: 0;
}

.row-snippet {
  color: var(--ib-row-snippet-color, #64748b);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.search-match-highlight {
  background-color: var(--ib-search-highlight-bg, #fef08a);
  color: var(--ib-search-highlight-color, #854d0e);
  font-weight: 600;
  padding: 1px 3px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--ib-search-highlight-border, rgba(202, 138, 4, 0.3));
  display: inline;
}

/* Attachments Chips Column */
.row-attachments {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--ib-att-bg, #f8fafc);
  border: 1px solid var(--ib-att-border, #e2e8f0);
  color: var(--ib-att-color, #475569);
  cursor: pointer;
  transition: all 0.15s ease;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.att-chip:hover {
  background: var(--ib-att-hover-bg, #f1f5f9);
  border-color: var(--ib-att-hover-border, #0284c7);
  color: var(--ib-att-hover-color, #0284c7);
  transform: translateY(-1px);
}

.att-chip.pdf {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
}

body.theme-dark .att-chip.pdf {
  color: #fca5a5;
}

.att-chip.pdf:hover {
  border-color: #ef4444;
  color: #991b1b;
}

body.theme-dark .att-chip.pdf:hover {
  color: #fee2e2;
}

.att-chip.excel {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.1);
  color: #15803d;
}

body.theme-dark .att-chip.excel {
  color: #6ee7b7;
}

.att-chip.image {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.1);
  color: #b45309;
}

body.theme-dark .att-chip.image {
  color: #fde68a;
}

.att-chip-icon {
  font-size: 0.75rem;
  flex-shrink: 0;
}

.att-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.att-chip-more {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--ib-att-bg, #f8fafc);
  color: var(--ib-text-muted, #64748b);
  border: 1px solid var(--ib-att-border, #e2e8f0);
}

/* Date Column */
.row-date {
  font-size: 0.78rem;
  color: var(--ib-row-date-color, #64748b);
  flex-shrink: 0;
  text-align: right;
  min-width: 75px;
}

/* Row Hover Action Buttons */
.row-actions {
  display: none;
  align-items: center;
  gap: 6px;
  position: absolute;
  right: 16px;
  background: var(--ib-row-hover-bg, #f8fafc);
  padding: 0 4px;
}

.inbox-row:hover .row-actions {
  display: flex;
}

.row-action-btn {
  background: var(--ib-btn-bg, #ffffff);
  border: 1px solid var(--ib-btn-border, #e2e8f0);
  color: var(--ib-btn-color, #64748b);
  font-size: 0.85rem;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.row-action-btn:hover {
  background: var(--ib-btn-hover-bg, #f1f5f9);
  color: var(--ib-btn-hover-color, #0f172a);
  border-color: var(--ib-btn-hover-border, #cbd5e1);
}

/* Loading & Empty States */
.inbox-loading-state,
.inbox-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--ib-empty-color, #64748b);
  gap: 12px;
  font-family: var(--font-sans);
}

.inbox-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--ib-spinner-border, rgba(2, 132, 199, 0.15));
  border-top-color: var(--ib-spinner-active, #0284c7);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ══════════════════════════════════════════════════════════════════════
   VIEW 2: DEDICATED CLEAN EMAIL THREAD VIEWER (AUTHENTIC GMAIL INTERFACE)
   ══════════════════════════════════════════════════════════════════════ */
body.view-workstation,
body.view-workstation .app-container {
  background: var(--ib-app-bg, #ffffff) !important;
}

body.theme-light.view-workstation,
body.theme-light.view-workstation .app-container {
  background: #ffffff !important;
}

body.theme-dark.view-workstation,
body.theme-dark.view-workstation .app-container {
  background: var(--ib-app-bg, #090d16) !important;
}

.workstation-view {
  display: flex;
  flex-direction: row;
  height: 100%;
  width: 100%;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  background: #ffffff;
  font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  position: relative;
}

body.theme-dark .workstation-view {
  background: var(--ib-app-bg, #090d16);
}

.thread-viewport {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  flex: 1 1 100%;
  min-width: 320px;
  margin: 0 !important;
  overflow: hidden;
  background: #ffffff;
  border: none !important;
  border-radius: 0 !important;
  position: relative;
  transition: flex 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

body.theme-dark .thread-viewport {
  background: var(--ib-app-bg, #090d16);
}

/* ── Workstation Dark Theme Overrides ── */
body.theme-dark .thread-nav-header {
  background: var(--ib-topbar-bg, #0f1523);
  border-bottom-color: var(--ib-topbar-border, #1e293b);
}

body.theme-dark .thread-header-subject {
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .thread-message-count-badge {
  color: var(--ib-text-muted, #94a3b8);
}

body.theme-dark .nav-back-btn,
body.theme-dark .nav-action-btn:not(.simulate-btn) {
  background: var(--ib-btn-bg, #131b2e);
  border-color: var(--ib-btn-border, #1e293b);
  color: var(--ib-btn-color, #94a3b8);
}

body.theme-dark .nav-back-btn:hover,
body.theme-dark .nav-action-btn:not(.simulate-btn):hover {
  background: var(--ib-btn-hover-bg, #1e293b);
  border-color: var(--ib-btn-hover-border, #334155);
  color: var(--ib-btn-hover-color, #e2e8f0);
}

body.theme-dark .clean-message-card {
  background: var(--ib-topbar-bg, #0f1523) !important;
  border-bottom-color: var(--ib-topbar-border, #1e293b) !important;
}

body.theme-dark .clean-message-card:last-child,
body.theme-dark .clean-message-card:has(+ .rfq-preflight-container),
body.theme-dark .clean-message-card:has(+ .inline-preflight-container),
body.theme-dark .clean-message-card.has-inline-preflight {
  border-bottom: none !important;
}

body.theme-dark .clean-message-card.collapsed:hover {
  background: var(--ib-btn-hover-bg, #1e293b) !important;
}

body.theme-dark .msg-sender-name {
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .msg-sender-email,
body.theme-dark .msg-to-line,
body.theme-dark .msg-date-stamp {
  color: var(--ib-text-muted, #94a3b8);
}

body.theme-dark .msg-collapsed-sender {
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .msg-collapsed-snippet {
  color: var(--ib-text-muted, #94a3b8);
}

body.theme-dark .gmail-actions-bar .gmail-pill-btn {
  background: var(--ib-btn-bg, #131b2e);
  border-color: var(--ib-btn-border, #1e293b);
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .gmail-actions-bar .gmail-pill-btn:hover {
  background: var(--ib-btn-hover-bg, #1e293b);
  border-color: var(--ib-btn-hover-border, #334155);
}

body.theme-dark .reply-card {
  background: var(--ib-topbar-bg, #0f1523);
  border-color: var(--ib-topbar-border, #1e293b);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

body.theme-dark .reply-header {
  border-bottom-color: var(--ib-topbar-border, #1e293b);
  color: var(--ib-text-muted, #94a3b8);
}

body.theme-dark .reply-mode-select-btn {
  background: var(--ib-btn-bg, #131b2e);
  border-color: var(--ib-btn-border, #1e293b);
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .reply-mode-select-btn:hover {
  background: var(--ib-btn-hover-bg, #1e293b);
}

body.theme-dark .reply-mode-menu {
  background: var(--ib-topbar-bg, #0f1523);
  border-color: var(--ib-topbar-border, #1e293b);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

body.theme-dark .reply-mode-option {
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .reply-mode-option:hover {
  background: var(--ib-btn-hover-bg, #1e293b);
}

body.theme-dark .reply-textarea {
  background: var(--ib-search-bg, #182235);
  border-color: var(--ib-search-border, #283548);
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .reply-textarea::placeholder {
  color: var(--ib-text-dim, #64748b);
}

body.theme-dark .forward-to-input {
  background: transparent;
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .attachment-side-panel {
  background: var(--ib-topbar-bg, #0f1523);
  border-left-color: var(--ib-topbar-border, #1e293b);
}

body.theme-dark .attachment-panel-header {
  background: var(--ib-topbar-bg, #0f1523);
  border-bottom-color: var(--ib-topbar-border, #1e293b);
}

body.theme-dark .panel-filename {
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .panel-meta-info {
  color: var(--ib-text-muted, #94a3b8);
}

body.theme-dark .panel-nav-group {
  background: var(--ib-btn-bg, #131b2e);
}

body.theme-dark .panel-nav-group .panel-icon-btn {
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .panel-nav-group .panel-icon-btn:hover:not(:disabled) {
  background: var(--ib-btn-hover-bg, #1e293b);
}

body.theme-dark .panel-nav-counter {
  color: var(--ib-text-muted, #94a3b8);
}

body.theme-dark .panel-action-btn {
  background: var(--ib-btn-bg, #131b2e);
  border-color: var(--ib-btn-border, #1e293b);
  color: var(--ib-brand-title, #38bdf8);
}

body.theme-dark .panel-action-btn:hover {
  background: var(--ib-btn-hover-bg, #1e293b);
  border-color: var(--ib-btn-hover-border, #334155);
}

body.theme-dark .panel-action-btn.download-btn {
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .panel-close-btn {
  color: var(--ib-text-muted, #94a3b8);
}

body.theme-dark .panel-close-btn:hover {
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .rfq-preflight-container:not(.card-collapsed) {
  background: var(--ib-topbar-bg, #0f1523);
  border-color: var(--ib-topbar-border, #1e293b);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

body.theme-dark .preflight-customer-chip {
  background: var(--ib-search-bg, #182235);
  border-color: var(--ib-search-border, #283548);
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .preflight-customer-chip .customer-chip-name {
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .preflight-sheet-picker {
  background: var(--ib-search-bg, #182235);
  border-color: var(--ib-search-border, #283548);
}

body.theme-dark .preflight-sheet-select {
  color: var(--ib-text-primary, #f8fafc);
  background: var(--ib-search-bg, #182235);
}

body.theme-dark .btn-location-toggle {
  background: var(--ib-search-bg, #182235);
  border-color: var(--ib-search-border, #283548);
  color: var(--ib-text-secondary, #94a3b8);
}

body.theme-dark .btn-location-toggle:hover {
  background: #1e293b;
  border-color: #475569;
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .btn-location-toggle.active {
  background: #1e1b4b;
  border-color: #6366f1;
  color: #c7d2fe;
}

body.theme-dark .btn-location-toggle .loc-toggle-pill.off {
  background: #334155;
  color: #94a3b8;
}

body.theme-dark .btn-location-toggle .loc-toggle-pill.on {
  background: #6366f1;
  color: #ffffff;
}

body.theme-dark .stock-tag.in-stock,
body.theme-dark .stock-tag.allocated {
  color: #4ade80;
}

body.theme-dark .stock-tag.in-stock .pf-status-dot,
body.theme-dark .stock-tag.allocated .pf-status-dot {
  background: #22c55e;
}

body.theme-dark .stock-tag.other-loc-stock {
  color: #818cf8;
}

body.theme-dark .stock-tag.other-loc-stock .pf-status-dot {
  background: #a5b4fc;
}

body.theme-dark .pf-stock-other-loc {
  color: #a5b4fc;
}

body.theme-dark .pf-other-loc-hint {
  color: #818cf8;
}

body.theme-dark .pf-other-loc-hint:hover {
  color: #c7d2fe;
}

body.theme-dark .pf-meta-cell .preflight-meta-strip,
body.theme-dark .preflight-meta-strip {
  background: var(--ib-search-bg, #182235);
  border-color: var(--ib-search-border, #283548);
  color: var(--ib-text-secondary, #94a3b8);
}

body.theme-dark .pf-meta-cell .preflight-meta-strip strong,
body.theme-dark .preflight-meta-strip strong {
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .rfq-preflight-container .grok-trace-header {
  background: var(--ib-search-bg, #182235);
  border-color: var(--ib-search-border, #283548);
  color: var(--ib-text-secondary, #94a3b8);
}

body.theme-dark .rfq-preflight-container .grok-trace-header:hover {
  background: #1e293b;
  border-color: #475569;
}

body.theme-dark .rfq-preflight-container .grok-step-icon-wrap {
  background: #1e293b;
  color: #94a3b8;
}

body.theme-dark .rfq-preflight-container .grok-step::before {
  background: #334155;
}

body.theme-dark .rfq-preflight-container .grok-step-title {
  color: #cbd5e1;
}

body.theme-dark .rfq-preflight-container .grok-step-header:hover .grok-step-title {
  color: #f8fafc;
}

body.theme-dark .rfq-preflight-container .grok-step.thought .grok-step-title {
  color: #94a3b8;
}

body.theme-dark .rfq-preflight-container .grok-step-detail {
  background: #0f172a;
  border: 1px solid #1e293b;
  color: #cbd5e1;
}

body.theme-dark .rfq-preflight-container .grok-detail-args {
  color: #e2e8f0;
}

body.theme-dark .rfq-preflight-container .grok-detail-res {
  color: #38bdf8;
}

body.theme-dark .btn-toggle-meta-mobile {
  background: var(--ib-search-bg, #182235);
  border-color: var(--ib-search-border, #283548);
  color: var(--ib-text-secondary, #94a3b8);
}

body.theme-dark .btn-toggle-meta-mobile:hover,
body.theme-dark .btn-toggle-meta-mobile:active {
  background: #1e293b;
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .btn-location-toggle .loc-toggle-text-mobile {
  color: var(--ib-text-secondary, #94a3b8);
}

body.theme-dark .preflight-table {
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .preflight-table th {
  background: var(--ib-btn-bg, #131b2e);
  border-color: var(--ib-topbar-border, #1e293b);
  color: var(--ib-text-muted, #94a3b8);
}

body.theme-dark .preflight-table td {
  border-color: var(--ib-topbar-border, #1e293b);
}

body.theme-dark .preflight-table tr:hover td {
  background: var(--ib-btn-hover-bg, #172238);
}

body.theme-dark .pf-line-note-pill {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fde68a;
}

body.theme-dark .pf-line-note-pill.pf-editable-note:hover {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.55);
}

body.theme-dark .pf-note-badge {
  background: rgba(245, 158, 11, 0.25);
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.45);
}

body.theme-dark .pf-btn-delete-note {
  color: #fde68a;
}

body.theme-dark .pf-btn-delete-note:hover {
  color: #f87171;
}

body.theme-dark .pf-btn-add-note {
  border-color: #475569;
  color: #94a3b8;
}

body.theme-dark .pf-btn-add-note:hover {
  border-color: #60a5fa;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.12);
}

body.theme-dark .pf-line-note-input {
  background: var(--ib-search-bg, #182235);
  border-color: var(--ib-search-border, #283548);
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .pf-btn-note-cancel {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

body.theme-dark .pf-btn-note-cancel:hover {
  background: #334155;
  color: #f8fafc;
}

body.theme-dark .preflight-history-select {
  background: var(--ib-search-bg, #182235);
  border-color: var(--ib-search-border, #283548);
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .preflight-run-pill {
  background: var(--ib-search-bg, #182235);
  border-color: var(--ib-search-border, #283548);
  color: var(--ib-text-muted, #94a3b8);
}

body.theme-dark .cyborg-typeahead-popover {
  background: var(--ib-topbar-bg, #0f1523);
  border-color: var(--ib-topbar-border, #1e293b);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
}

body.theme-dark .typeahead-search-input {
  background: var(--ib-search-bg, #182235);
  border-color: var(--ib-search-border, #283548);
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .typeahead-result-item {
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .typeahead-result-item:hover,
body.theme-dark .typeahead-result-item.highlighted {
  background: var(--ib-btn-hover-bg, #1e293b);
  color: var(--ib-brand-title, #38bdf8);
}


/* ── Thread Top Header (Gmail Style) ── */
.thread-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
  gap: 16px;
  z-index: 5;
}

.thread-nav-header:has(+ #threadBodyScroll > #rfqPreflightContainer.card-collapsed:not([style*="display: none"])) {
  border-bottom: none !important;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
}

.nav-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 6px;
  color: #3c4043;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.nav-back-btn:hover {
  background: #f1f3f4;
  color: #202124;
  border-color: #bdc1c6;
}

.thread-header-meta {
  min-width: 0;
  flex: 1;
}

.thread-header-subject {
  font-family: Roboto, 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 1.35rem;
  font-weight: 500;
  color: #202124;
  margin: 0 0 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.thread-tags-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.thread-category-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #e8f0fe;
  color: #1967d2;
  border: 1px solid #d2e3fc;
}

.thread-message-count-badge {
  font-size: 0.75rem;
  color: #5f6368;
  font-weight: 500;
}

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

.nav-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 6px;
  color: #5f6368;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-action-btn:hover {
  background: #f1f3f4;
  color: #202124;
  border-color: #bdc1c6;
}

.nav-action-btn.simulate-btn {
  background: #fdf4ff;
  border-color: #f0abfc;
  color: #a21caf;
  font-weight: 600;
}

.nav-action-btn.simulate-btn:hover {
  background: #fae8ff;
  border-color: #e879f9;
  color: #86198f;
  box-shadow: 0 1px 4px rgba(162, 28, 175, 0.18);
}

.nav-action-btn.simulate-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.pf-spin {
  animation: spinPreflightIcon 0.9s linear infinite;
  display: inline-block;
}

.star-toggle-btn {
  font-size: 1.15rem;
  padding: 3px 8px;
  color: #5f6368;
  line-height: 1;
}

.star-toggle-btn.active,
.star-toggle-btn:hover {
  color: #f29900;
}

/* ── Unified Scrollable Thread Body (Pre-Flight Card + Message Stream) ── */
.thread-body-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  width: 100%;
  box-sizing: border-box;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #dadce0 transparent;
}

.thread-body-scroll::-webkit-scrollbar {
  width: 8px;
}

.thread-body-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.thread-body-scroll::-webkit-scrollbar-thumb {
  background: #dadce0;
  border-radius: 4px;
}

.thread-body-scroll::-webkit-scrollbar-thumb:hover {
  background: #bdc1c6;
}

/* ── Full Width Thread Messages Stream ── */
.thread-messages-stream {
  flex: 1;
  overflow: visible !important;
  padding: 0 28px 24px 28px;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  box-sizing: border-box;
  width: 100%;
}

/* ── Gmail Message Card (Flat Stacking, No Border Box!) ── */
.clean-message-card {
  background: #ffffff !important;
  border: none !important;
  border-bottom: 1px solid #e0e0e0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  width: 100%;
  margin: 0;
  padding: 14px 0 18px 0;
  box-sizing: border-box;
  font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  transition: background 0.12s ease;
}

.clean-message-card:last-child,
.clean-message-card:has(+ .rfq-preflight-container),
.clean-message-card:has(+ .inline-preflight-container),
.clean-message-card.has-inline-preflight {
  border-bottom: none !important;
}

.clean-message-card:has(+ .rfq-preflight-container.card-collapsed),
.clean-message-card:has(+ .inline-preflight-container.card-collapsed),
.clean-message-card.has-inline-preflight {
  padding-bottom: 8px !important;
}

/* Expanded Header Row */
.msg-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 2px 0 4px 0;
  background: transparent;
  border: none;
  cursor: pointer;
  user-select: none;
  gap: 12px;
}

.msg-header-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.msg-sender-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.05rem;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  letter-spacing: normal;
}

.msg-sender-info {
  min-width: 0;
  flex: 1;
}

.msg-sender-name-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.msg-sender-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #202124;
}

.msg-sender-email {
  font-size: 0.8rem;
  color: #5f6368;
}

.msg-to-line {
  font-size: 0.78rem;
  color: #5f6368;
  margin-top: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border-radius: 3px;
  padding: 1px 4px;
  transition: background 0.12s ease;
}

.msg-to-line:hover {
  background: #f1f3f4;
  color: #202124;
}

.msg-to-dropdown {
  display: none;
  margin-top: 6px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 0.8rem;
  color: #3c4043;
  line-height: 1.6;
  max-width: 480px;
}

.msg-to-dropdown.open {
  display: block;
}

.msg-to-dropdown div {
  margin-bottom: 2px;
}

.msg-to-dropdown strong {
  color: #5f6368;
  font-weight: 500;
  width: 60px;
  display: inline-block;
}

.msg-snippet-preview {
  display: none;
}

.msg-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.msg-date-stamp {
  font-size: 0.8rem;
  color: #5f6368;
  white-space: nowrap;
}

.msg-collapse-chevron {
  color: #5f6368;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  background: transparent;
  border: none;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}

.msg-collapse-chevron:hover {
  background: #f1f3f4;
  color: #202124;
}

/* ── Thread Top Actions More Menu (Forward all) ── */
.thread-top-menu-wrap {
  position: relative;
  display: inline-flex;
}

.thread-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
  min-width: 32px;
}

.thread-more-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  z-index: 100;
  min-width: 160px;
  padding: 6px 0;
  display: flex;
  flex-direction: column;
}

body.theme-dark .thread-more-dropdown {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.thread-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  color: #3c4043;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
  width: 100%;
}

.thread-dropdown-item:hover {
  background: #f1f3f4;
  color: #1f1f1f;
}

body.theme-dark .thread-dropdown-item {
  color: #cbd5e1;
}

body.theme-dark .thread-dropdown-item:hover {
  background: #334155;
  color: #f8fafc;
}

/* ── Individual Message Header Action Buttons & More Menu ── */
.msg-action-icon-btn,
.msg-more-btn {
  background: transparent;
  border: none;
  color: #5f6368;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}

.msg-action-icon-btn:hover,
.msg-more-btn:hover {
  background: #f1f3f4;
  color: #202124;
}

body.theme-dark .msg-action-icon-btn,
body.theme-dark .msg-more-btn {
  color: #94a3b8;
}

body.theme-dark .msg-action-icon-btn:hover,
body.theme-dark .msg-more-btn:hover {
  background: #334155;
  color: #f8fafc;
}

.msg-more-menu-wrap {
  position: relative;
  display: inline-flex;
}

.msg-actions-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  z-index: 100;
  min-width: 140px;
  padding: 5px 0;
  display: flex;
  flex-direction: column;
}

body.theme-dark .msg-actions-dropdown {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.msg-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: #3c4043;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
  width: 100%;
  white-space: nowrap;
}

.msg-dropdown-item:hover {
  background: #f1f3f4;
  color: #1a73e8;
}

body.theme-dark .msg-dropdown-item {
  color: #cbd5e1;
}

body.theme-dark .msg-dropdown-item:hover {
  background: #334155;
  color: #38bdf8;
}

/* ── Gmail Collapsed 1-Line Preview Row (Image 3) ── */
.clean-message-card.collapsed {
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 4px;
}

.clean-message-card.collapsed:hover {
  background: #f8f9fa !important;
}

.clean-message-card.collapsed .msg-card-header {
  align-items: center;
  padding: 0;
}

.clean-message-card.collapsed .msg-sender-avatar {
  width: 32px;
  height: 32px;
  font-size: 0.85rem;
}

.clean-message-card.collapsed .msg-header-left {
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.clean-message-card.collapsed .msg-sender-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.clean-message-card.collapsed .msg-sender-name-row {
  flex-shrink: 0;
}

.clean-message-card.collapsed .msg-sender-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: #202124;
  white-space: nowrap;
  flex-shrink: 0;
  margin-right: 4px;
}

.clean-message-card.collapsed .msg-sender-email {
  display: none;
}

.clean-message-card.collapsed .msg-to-line {
  display: none;
}

.clean-message-card.collapsed .msg-to-dropdown {
  display: none !important;
}

.clean-message-card.collapsed .msg-snippet-preview {
  display: block;
  font-size: 0.85rem;
  color: #5f6368;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  margin: 0;
}

.clean-message-card.collapsed .msg-collapse-chevron {
  display: none;
}

.clean-message-card.collapsed .msg-body-host,
.clean-message-card.collapsed .msg-clean-body,
.clean-message-card.collapsed .msg-attachments-section,
.clean-message-card.collapsed .msg-quoted-wrapper {
  display: none !important;
}

/* ── Message Body Host (Aligned Under Sender Text) ── */
.msg-body-host,
.msg-clean-body {
  padding: 10px 0 16px 52px;
  color: #202124;
  font-size: 0.92rem;
  line-height: 1.55;
  font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  word-break: break-word;
  box-sizing: border-box;
}

.msg-clean-body p {
  margin: 0 0 12px 0;
}

.msg-clean-body p:last-child {
  margin-bottom: 0;
}

/* ── Collapsible Quoted History (Gmail ...) ── */
.msg-quoted-wrapper {
  margin: 0 0 12px 52px;
}

.btn-toggle-quoted {
  background: #f1f3f4;
  border: 1px solid #dadce0;
  color: #5f6368;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.btn-toggle-quoted:hover {
  background: #e8eaed;
  color: #202124;
}

.msg-quoted-content {
  display: none;
  margin-top: 8px;
  padding: 8px 12px;
  border-left: 2px solid #dadce0;
  color: #5f6368;
  font-size: 0.84rem;
  line-height: 1.5;
  background: #f8f9fa;
  border-radius: 0 4px 4px 0;
  white-space: pre-wrap;
}

.msg-quoted-content.open {
  display: block;
}

/* ── Gmail Attachments Block (Indented 52px, Image 2) ── */
.msg-attachments-section {
  padding: 10px 0 16px 52px;
  border-top: none;
  background: transparent;
  box-sizing: border-box;
}

.msg-attachments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.84rem;
  color: #5f6368;
}

.att-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: #3c4043;
}

.att-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.att-header-btn {
  background: none;
  border: none;
  color: #5f6368;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.att-header-btn:hover {
  background: #f1f3f4;
  color: #202124;
}

.msg-attachments-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.msg-attachment-card {
  width: 190px;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.08);
  transition: all 0.2s ease;
  position: relative;
  text-decoration: none;
}

.msg-attachment-card:hover {
  border-color: #bdc1c6;
  box-shadow: 0 1px 4px 1px rgba(60, 64, 67, 0.18);
}

.msg-att-thumb {
  width: 100%;
  height: 95px;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  user-select: none;
}

.msg-att-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* PDF Card Preview - Matching Image 2 with red ribbon */
.pdf-card-preview {
  position: relative;
  width: 52px;
  height: 64px;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  padding: 8px 6px;
  box-sizing: border-box;
}

.pdf-tag {
  position: absolute;
  bottom: 0;
  left: 0;
  background: #ea4335;
  color: #ffffff;
  font-size: 0.58rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 0 4px 0 4px;
  letter-spacing: 0.04em;
  line-height: 1;
}

.doc-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}

.doc-line {
  height: 2px;
  background: #dadce0;
  border-radius: 1px;
}

.doc-line.l1 { width: 100%; }
.doc-line.l2 { width: 80%; }
.doc-line.l3 { width: 55%; }

/* Excel Card Preview */
.excel-thumb {
  background: #f1f8f5;
}

.excel-card-preview {
  position: relative;
  width: 52px;
  height: 64px;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  padding: 8px 6px;
  box-sizing: border-box;
}

.excel-tag {
  position: absolute;
  bottom: 0;
  left: 0;
  background: #1e8e3e;
  color: #ffffff;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 2px 4px;
  border-radius: 0 4px 0 4px;
  letter-spacing: 0.04em;
  line-height: 1;
}

/* Generic / Other Thumbnail */
.generic-thumb {
  background: #f8f9fa;
}

.generic-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 1.5rem;
  color: #5f6368;
}

.generic-badge .ext-name {
  font-size: 0.68rem;
  font-weight: 700;
  color: #5f6368;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Card Footer */
.att-card-footer {
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border-top: 1px solid #f1f3f4;
  min-width: 0;
  height: 44px;
  box-sizing: border-box;
}

.att-type-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 6px;
}

.att-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.att-meta .att-filename {
  font-size: 0.8rem;
  font-weight: 500;
  color: #3c4043;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.att-meta .att-filesize {
  font-size: 0.7rem;
  color: #5f6368;
  margin-top: 2px;
}

.att-download-action {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  color: #5f6368;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-decoration: none;
  transition: all 0.15s ease;
  margin-left: 6px;
}

.att-download-action:hover {
  background: #f1f3f4;
  color: #202124;
}

/* ── Gmail-Style Action Buttons & Bottom Reply Composer ── */
.thread-bottom-action-area {
  margin-top: 10px;
  flex-shrink: 0;
  background: transparent;
}

.gmail-actions-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 28px 24px 28px;
  background: transparent;
  box-sizing: border-box;
}

.gmail-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 24px;
  border-radius: 9999px;
  border: 1px solid #747775;
  background: #ffffff;
  color: #1f1f1f;
  font-family: Roboto, 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  cursor: pointer;
  outline: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  user-select: none;
  white-space: nowrap;
}

.gmail-pill-btn svg {
  color: #444746;
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.gmail-pill-btn:hover {
  background-color: #f2f2f2;
  border-color: #444746;
}

.gmail-pill-btn:hover svg {
  color: #1f1f1f;
}

.gmail-pill-btn:active {
  background-color: #e5e5e5;
  transform: scale(0.98);
}

.gmail-circle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid #747775;
  background: #ffffff;
  color: #444746;
  cursor: pointer;
  outline: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
  flex-shrink: 0;
}

.gmail-circle-btn:hover {
  background-color: #f2f2f2;
  border-color: #444746;
  color: #1f1f1f;
}

.gmail-circle-btn:active {
  background-color: #e5e5e5;
  transform: scale(0.95);
}

/* Reaction Popover */
.gmail-reaction-wrapper {
  position: relative;
}

.gmail-reaction-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 28px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 4px 16px rgba(60, 64, 67, 0.2);
  z-index: 50;
  animation: popoverFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popoverFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.reaction-emoji-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.12s ease;
}

.reaction-emoji-btn:hover {
  transform: scale(1.25);
  background-color: #f1f3f4;
}

/* ── Inline Reply Composer ── */
.thread-reply-section {
  padding: 0 28px 24px 28px;
  background: transparent;
  flex-shrink: 0;
  box-sizing: border-box;
}

.reply-card {
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.12);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.reply-card:focus-within {
  border-color: #0b57d0;
  box-shadow: 0 1px 4px 1px rgba(11, 87, 208, 0.2);
}

.reply-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f3f4;
  font-size: 0.85rem;
  color: #5f6368;
}

.reply-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.reply-mode-dropdown-wrap {
  position: relative;
  flex-shrink: 0;
}

.reply-mode-select-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  background: #f1f3f4;
  border: 1px solid transparent;
  color: #3c4043;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.reply-mode-select-btn:hover {
  background: #e8eaed;
  color: #1f1f1f;
}

.reply-mode-icon {
  display: inline-flex;
  align-items: center;
  color: #444746;
}

.reply-mode-caret {
  font-size: 0.72rem;
  color: #5f6368;
}

.reply-mode-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  z-index: 60;
  min-width: 140px;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
}

.reply-mode-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.82rem;
  color: #3c4043;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  width: 100%;
}

.reply-mode-option:hover {
  background: #f1f3f4;
  color: #1f1f1f;
}

.reply-recipients-wrap {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
}

.reply-label {
  font-weight: 500;
  color: #3c4043;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.forward-to-input-wrap,
.reply-cc-row,
.forward-subject-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 0;
  border-bottom: 1px solid #f1f3f4;
}

.forward-to-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: #5f6368;
  flex-shrink: 0;
  min-width: 48px;
}

.forward-to-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.88rem;
  color: #202124;
  background: transparent;
  padding: 2px 0;
}

.forward-to-input:focus {
  border-bottom: 1px solid #0b57d0;
}

.reply-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-recipient-toggle {
  background: transparent;
  border: none;
  color: #5f6368;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-recipient-toggle:hover {
  background: #f1f3f4;
  color: #1f1f1f;
}

.btn-recipient-toggle.active {
  background: #e8f0fe;
  color: #0b57d0;
}

.reply-textarea {
  width: 100%;
  min-height: 85px;
  max-height: 650px;
  background: #ffffff;
  border: none;
  outline: none;
  padding: 4px 0;
  color: #202124;
  font-family: Roboto, -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 0.92rem;
  line-height: 1.55;
  resize: none;
  overflow-y: auto;
  box-sizing: border-box;
}

.reply-textarea::placeholder {
  color: #80868b;
}

.reply-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}

.reply-footer-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reply-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-discard-reply {
  background: transparent;
  border: none;
  color: #5f6368;
  font-family: inherit;
  font-size: 0.84rem;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-discard-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
}

.btn-discard-reply:hover {
  color: #d93025;
  background: #fce8e6;
}

/* Staged Attachments in Reply Composer */
.composer-attachments-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0 10px 0;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
}

.staged-att-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.82rem;
  color: #1e293b;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.15s ease;
}

.staged-att-pill.pdf {
  border-color: #fecaca;
  background: #fff5f5;
}

.staged-att-icon {
  font-size: 1.05rem;
}

.staged-att-name {
  font-weight: 500;
  color: #0f172a;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.staged-att-badge-tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #dc2626;
  background: #fee2e2;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

.staged-att-preview {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #2563eb;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 7px;
  background: #eff6ff;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.staged-att-preview:hover {
  background: #dbeafe;
  color: #1d4ed8;
}

.staged-att-remove {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9rem;
  line-height: 1;
  transition: all 0.15s ease;
}

.staged-att-remove:hover {
  color: #ef4444;
  background: #fee2e2;
}

.btn-send-reply {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #0b57d0;
  border: none;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 8px 24px;
  border-radius: 18px;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3);
}

.btn-send-reply:hover {
  background: #0842a0;
  box-shadow: 0 1px 3px 1px rgba(60, 64, 67, 0.35);
}

.btn-send-reply:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Workstation Attachment Resizer ── */
.workstation-resizer {
  width: 6px;
  background: #e8eaed;
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.15s, box-shadow 0.15s;
  z-index: 10;
  position: relative;
}

.workstation-resizer:hover,
.workstation-resizer.dragging {
  background: #1a73e8;
  box-shadow: 0 0 6px rgba(26, 115, 232, 0.4);
}

/* ══════════════════════════════════════════════════════════════════════
   ATTACHMENT SIDE PANEL (RIGHT SIDE OF SCREEN)
   ══════════════════════════════════════════════════════════════════════ */
.attachment-side-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 48%;
  min-width: 360px;
  max-width: 75%;
  height: 100%;
  background: #ffffff;
  border-left: 1px solid #dadce0;
  position: relative;
  z-index: 15;
  box-shadow: -4px 0 16px rgba(60, 64, 67, 0.06);
  transition: flex 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.attachment-side-panel.collapsed {
  display: none !important;
}

.attachment-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  min-height: 54px;
  background: #ffffff;
  border-bottom: 1px solid #dadce0;
  gap: 12px;
  flex-shrink: 0;
}

.panel-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.panel-att-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.panel-att-badge.pdf {
  background: #fce8e6;
  color: #c5221f;
  border: 1px solid #f6aea9;
}

.panel-att-badge.excel {
  background: #e6f4ea;
  color: #137333;
  border: 1px solid #a8dab5;
}

.panel-att-badge.image {
  background: #f3e8fd;
  color: #8430ce;
  border: 1px solid #d7aefb;
}

.panel-att-badge.doc,
.panel-att-badge.other {
  background: #e8f0fe;
  color: #1a73e8;
  border: 1px solid #aecbfa;
}

.panel-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-filename {
  font-size: 0.88rem;
  font-weight: 600;
  color: #202124;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  line-height: 1.3;
}

.panel-meta-info {
  font-size: 0.73rem;
  color: #5f6368;
  margin-top: 1px;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.panel-nav-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: #f1f3f4;
  border-radius: 6px;
  padding: 2px 4px;
  margin-right: 2px;
}

.panel-nav-group .panel-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: #3c4043;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s ease;
}

.panel-nav-group .panel-icon-btn:hover:not(:disabled) {
  background: #e8eaed;
  color: #202124;
}

.panel-nav-group .panel-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.panel-nav-counter {
  font-size: 0.75rem;
  font-weight: 600;
  color: #5f6368;
  padding: 0 6px;
  min-width: 36px;
  text-align: center;
}

.panel-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid #dadce0;
  background: #ffffff;
  color: #1a73e8;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.panel-action-btn:hover {
  background: #f1f3f4;
  border-color: #c6c9cc;
}

.panel-action-btn.download-btn {
  color: #3c4043;
}

.panel-action-btn.download-btn:hover {
  background: #f1f3f4;
  color: #202124;
}

.panel-close-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 1.3rem;
  color: #5f6368;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.panel-close-btn:hover {
  background: #f1f3f4;
  color: #202124;
}

/* Panel Body */
.attachment-panel-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #202124; /* Dark neutral stage so white PDFs and drawings pop with high contrast */
  position: relative;
}

.panel-preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

.panel-preview-image-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  box-sizing: border-box;
}

.panel-preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  background: #ffffff;
}

.panel-loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #9aa0a6;
  font-size: 0.85rem;
}

.panel-spinner-ring {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: panelSpin 0.8s linear infinite;
}

@keyframes panelSpin {
  to { transform: rotate(360deg); }
}

/* Fallback Card for Excel / Non-visual files */
.panel-preview-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 36px 28px;
  max-width: 440px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #dadce0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  margin: auto;
}

.panel-card-icon {
  font-size: 40px;
  margin-bottom: 14px;
  width: 68px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
}

.panel-card-icon.excel {
  background: #e6f4ea;
  color: #137333;
}

.panel-card-icon.pdf {
  background: #fce8e6;
  color: #c5221f;
}

.panel-card-icon.image {
  background: #f3e8fd;
  color: #8430ce;
}

.panel-card-icon.other {
  background: #e8f0fe;
  color: #1a73e8;
}

.panel-card-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: #202124;
  margin-bottom: 6px;
  word-break: break-word;
}

.panel-card-meta {
  font-size: 0.82rem;
  color: #5f6368;
  margin-bottom: 12px;
}

.panel-card-note {
  font-size: 0.82rem;
  color: #5f6368;
  line-height: 1.45;
  margin-bottom: 22px;
}

.panel-card-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  justify-content: center;
}

.panel-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #1a73e8;
  color: #ffffff;
  padding: 9px 18px;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease;
}

.panel-btn-primary:hover {
  background: #1765cc;
}

.panel-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
  padding: 9px 16px;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
}

.panel-btn-secondary:hover {
  background: #f1f3f4;
  border-color: #c6c9cc;
}

/* Active attachment card state in message card */
.msg-attachment-card.active-attachment {
  border-color: #1a73e8 !important;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.4), 0 2px 8px rgba(26, 115, 232, 0.15) !important;
  background: #f8fafd !important;
  position: relative;
}

.msg-attachment-card.active-attachment::after {
  content: 'Viewing';
  position: absolute;
  top: 6px;
  right: 6px;
  background: #1a73e8;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  z-index: 5;
}

/* Lightbox Modal (Retained as Fallback) */
.attachment-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--ib-modal-backdrop, rgba(0, 0, 0, 0.75));
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  z-index: 101;
  width: 90vw;
  max-width: 960px;
  height: 85vh;
  background: var(--ib-modal-bg, #ffffff);
  border: 1px solid var(--ib-modal-border, #e2e8f0);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--ib-modal-border, #e2e8f0);
  background: var(--ib-modal-header-bg, #f8fafc);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.modal-header h3 {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--ib-modal-text, #0f172a);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-btn-download {
  background: var(--ib-modal-btn-download-bg, #0284c7);
  color: var(--ib-modal-btn-download-color, #ffffff);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 5px;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.modal-btn-download:hover {
  opacity: 0.9;
}

.modal-btn-close {
  background: none;
  border: none;
  color: var(--ib-text-muted, #94a3b8);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease;
}

.modal-btn-close:hover {
  color: var(--ib-text-primary, #0f172a);
}

.modal-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ib-app-bg, #f8fafc);
}

.modal-body iframe,
.modal-body img {
  width: 100%;
  height: 100%;
  border: none;
  object-fit: contain;
}

/* ── Mobile Layout Adjustments ── */
@media (max-width: 768px) {
  .workstation-view {
    flex-direction: column !important;
  }

  .resizer.workstation-resizer {
    display: none !important;
  }

  .attachment-side-panel {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    z-index: 100;
    border-left: none;
    box-shadow: none;
  }

  .attachment-side-panel.collapsed {
    display: none !important;
  }

  .panel-header-actions .panel-action-btn span.panel-action-text {
    display: none;
  }

  .thread-viewport {
    max-width: 100% !important;
    border: none !important;
  }

  .thread-nav-header {
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .thread-header-subject {
    font-size: 1.05rem;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .thread-attachments-strip {
    padding: 8px 12px;
  }

  .thread-messages-stream {
    padding: 0 12px 18px 12px !important;
    gap: 0 !important;
  }

  .clean-message-card {
    padding: 12px 0 14px 0 !important;
  }

  .msg-card-header {
    padding: 2px 0 4px 0;
  }

  .msg-header-right {
    gap: 4px !important;
  }

  .msg-action-icon-btn,
  .msg-more-btn {
    padding: 4px;
    min-width: 28px;
    min-height: 28px;
  }

  .msg-date-stamp {
    font-size: 0.75rem;
  }

  .msg-sender-avatar {
    width: 34px;
    height: 34px;
    font-size: 0.85rem;
  }

  .msg-clean-body,
  .msg-body-host,
  .msg-attachments-section,
  .msg-quoted-wrapper {
    padding-left: 0 !important;
  }

  .clean-message-card.collapsed {
    padding: 8px 6px !important;
  }

  .clean-message-card.collapsed .msg-sender-name {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .clean-message-card.collapsed .msg-snippet-preview {
    font-size: 0.82rem;
  }

  .msg-attachment-card {
    width: calc(100% - 4px);
    max-width: 280px;
  }

  .gmail-actions-bar {
    padding: 10px 14px 18px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .gmail-pill-btn {
    height: 36px;
    padding: 0 16px;
    font-size: 13px;
    gap: 6px;
  }

  .gmail-circle-btn {
    width: 36px;
    height: 36px;
  }

  .thread-reply-section {
    padding: 0 14px 18px 14px;
  }

  .reply-textarea {
    min-height: 75px;
    max-height: 380px;
  }

  .row-senders {
    width: 110px;
    min-width: 110px;
  }

  .row-subject {
    max-width: 55%;
  }
}

@media (max-width: 480px) {
  .thread-nav-header {
    padding: 8px 10px;
  }

  .nav-action-btn {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  .msg-attachment-card {
    width: 100%;
    max-width: 100%;
  }

  .msg-sender-name {
    font-size: 0.88rem;
  }

  .msg-date-stamp {
    font-size: 0.72rem;
  }
}

/* ══════════════════════════════════════════════════════════════════════ */
/* CYBORG RFQ PRE-FLIGHT & ESTIMATE CARD                                  */
/* ══════════════════════════════════════════════════════════════════════ */
.rfq-preflight-container {
  margin: 10px 24px 8px 24px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
  font-family: inherit;
  animation: fadeInPreflight 0.2s ease-out;
  flex-shrink: 0;
  transition: padding 0.2s ease, box-shadow 0.2s ease;
}

.rfq-preflight-container:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

.rfq-preflight-container.inline-preflight-container {
  margin: 12px 0 14px 0;
  width: 100%;
  box-sizing: border-box;
}

/* ── Pre-flight Header Icon Pulse Animation ── */
.preflight-loading-pulse {
  font-size: 0.9rem;
  animation: spinPreflightIcon 1.2s infinite ease-in-out;
  display: inline-block;
}

@keyframes spinPreflightIcon {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ── Inline Collapsed Milestone Pill for Earlier Runs ── */
.preflight-inline-pill-wrapper {
  width: 100%;
  box-sizing: border-box;
  margin: 8px 0 12px 0;
}

.preflight-inline-pill {
  width: 100%;
  box-sizing: border-box;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.preflight-inline-pill:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.preflight-inline-pill.is-open {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
  background: #f1f5f9;
}

.preflight-inline-pill .pill-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.preflight-inline-pill .pill-badge {
  font-size: 0.68rem;
  background: #e0e7ff;
  color: #3730a3;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.preflight-inline-pill .pill-run {
  font-size: 0.78rem;
  font-weight: 700;
  color: #1e293b;
}

.preflight-inline-pill .pill-meta {
  font-size: 0.78rem;
  color: #64748b;
  font-weight: 500;
}

.preflight-inline-pill .pill-toggle {
  font-size: 0.76rem;
  color: #0284c7;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.preflight-inline-expanded {
  margin-bottom: 12px;
  animation: fadeInPreflight 0.2s ease-out;
}

/* ── Minimalist Toggle / Minimize Button ── */
.btn-toggle-preflight-card {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: transparent;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 0.74rem;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  height: 26px;
  box-sizing: border-box;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-toggle-preflight-card:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

/* ── Sleek Collapsed Linear Solutions Horizontal Line Bar ── */
.rfq-preflight-container.card-collapsed {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 4px 0 !important;
  margin: 6px 0 !important;
  cursor: pointer;
  user-select: none;
  width: 100%;
}

.rfq-preflight-container:not(.card-collapsed) .preflight-collapsed-bar {
  display: none !important;
}

.rfq-preflight-container.card-collapsed .preflight-expanded-content {
  display: none !important;
}

.preflight-collapsed-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 2px 0;
  transition: all 0.2s ease;
  cursor: pointer;
  touch-action: manipulation;
}

.pf-bar-line {
  height: 1px;
  flex: 1;
  min-width: 12px;
  transition: all 0.25s ease;
}

.pf-bar-line-left {
  background: linear-gradient(90deg, transparent 0%, #cbd5e1 50%, rgba(56, 189, 248, 0.7) 100%);
}

.pf-bar-line-right {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.7) 0%, #cbd5e1 50%, transparent 100%);
}

.pf-bar-content {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px 3px 10px;
  border-radius: 9999px;
  background: #0f172a; /* Linear Solutions Deep Navy */
  border: 1px solid rgba(56, 189, 248, 0.4); /* Electric Cyan Border */
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12), 0 0 10px rgba(56, 189, 248, 0.15);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  flex-shrink: 0;
}

.pf-bar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #38bdf8; /* Linear Solutions Cyan Accent */
  filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.6));
}

.pf-bar-brand {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #f8fafc;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.pf-bar-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #38bdf8;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.12);
}

.pf-bar-run {
  font-size: 0.65rem;
  font-weight: 600;
  color: #94a3b8;
  font-family: 'JetBrains Mono', monospace;
}

.pf-bar-subtotal {
  font-size: 0.72rem;
  font-weight: 700;
  color: #34d399; /* Emerald dollar revenue indicator */
  font-variant-numeric: tabular-nums;
  margin-left: 2px;
}

.pf-bar-chevron {
  display: inline-flex;
  align-items: center;
  color: #94a3b8;
  font-size: 0.75rem;
  margin-left: 2px;
  transition: transform 0.2s ease, color 0.2s ease;
}

/* Hover Interactions on the Sleek Line */
.rfq-preflight-container.card-collapsed:hover .pf-bar-content {
  background: #09101f;
  border-color: #38bdf8;
  box-shadow: 0 2px 14px rgba(56, 189, 248, 0.35), 0 0 18px rgba(56, 189, 248, 0.25);
  transform: translateY(-1px);
}

.rfq-preflight-container.card-collapsed:hover .pf-bar-chevron {
  color: #38bdf8;
  transform: translateY(1px);
}

.rfq-preflight-container.card-collapsed:hover .pf-bar-line-left {
  background: linear-gradient(90deg, transparent 0%, #38bdf8 65%, #0284c7 100%);
}

.rfq-preflight-container.card-collapsed:hover .pf-bar-line-right {
  background: linear-gradient(90deg, #0284c7 0%, #38bdf8 35%, transparent 100%);
}

.rfq-preflight-container.card-collapsed:active .pf-bar-content {
  transform: scale(0.97);
  box-shadow: 0 1px 5px rgba(56, 189, 248, 0.2);
}

@keyframes fadeInPreflight {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Unified Minimalist Header Single-Row Bar ── */
.preflight-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  position: relative;
  margin-bottom: 6px;
  flex-wrap: wrap;
  width: 100%;
}

.pf-header-left,
.preflight-header-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.preflight-secondary-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pf-header-right,
.preflight-header-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.pf-emoji {
  display: inline;
}

.pf-meta-cell {
  display: inline-flex;
  align-items: center;
  flex-shrink: 1;
  min-width: 0;
}

.btn-toggle-meta-mobile {
  display: none;
}

.loc-toggle-text-mobile {
  display: none;
}

.preflight-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 4px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.preflight-run-pill {
  font-size: 0.74rem;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

.preflight-history-select {
  font-size: 0.74rem;
  padding: 2px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #f8fafc;
  color: #475569;
  font-weight: 500;
  cursor: pointer;
  height: 26px;
  outline: none;
  transition: all 0.15s ease;
}

.preflight-history-select:focus {
  border-color: #0284c7;
}

/* ── Customer Chip in Header ── */
.preflight-customer-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 0.8rem;
  color: #334155;
  height: 26px;
  box-sizing: border-box;
  transition: all 0.15s ease;
  user-select: none;
}

.preflight-customer-chip.pf-customer-chip {
  cursor: pointer;
}

.preflight-customer-chip.pf-customer-chip:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.preflight-customer-chip .customer-chip-label {
  color: #64748b;
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.preflight-customer-chip .customer-chip-name {
  color: #0f172a;
  font-weight: 600;
}

.customer-edit-arrow {
  font-size: 0.68rem;
  color: #64748b;
  margin-left: 2px;
}

/* ── Price Sheet Inline Picker in Header ── */
.preflight-sheet-picker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 0 4px 0 8px;
  height: 26px;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.preflight-sheet-picker:hover {
  border-color: #94a3b8;
}

.preflight-sheet-picker .sheet-control-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.preflight-sheet-select {
  border: none;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 600;
  color: #0f172a;
  padding: 0 2px;
  outline: none;
  cursor: pointer;
  max-width: 170px;
}



/* ── Check Other Locations Toggle (Option A) ── */
.preflight-location-toggle-wrap {
  display: inline-flex;
  align-items: center;
}

.btn-location-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 0 7px;
  height: 26px;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-location-toggle:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.btn-location-toggle.active {
  background: #eef2ff;
  border-color: #818cf8;
  color: #3730a3;
  box-shadow: 0 1px 2px rgba(99, 102, 241, 0.12);
}

.btn-location-toggle.active:hover {
  background: #e0e7ff;
  border-color: #6366f1;
  color: #312e81;
}

.btn-location-toggle .loc-toggle-icon {
  font-size: 0.85rem;
  line-height: 1;
}

.btn-location-toggle .loc-toggle-text {
  line-height: 1;
}

.btn-location-toggle .loc-toggle-pill {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 10px;
  line-height: 1.2;
}

.btn-location-toggle .loc-toggle-pill.off {
  background: #e2e8f0;
  color: #64748b;
}

.btn-location-toggle .loc-toggle-pill.on {
  background: #4f46e5;
  color: #ffffff;
}

/* ── Subtotal & Estimate Badges ── */
.pf-subtotal-group {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}

.pf-header-timestamp {
  font-size: 0.72rem;
  font-weight: 500;
  color: #64748b;
  white-space: nowrap;
  letter-spacing: -0.01em;
  opacity: 0.85;
}

body.theme-dark .pf-header-timestamp {
  color: #94a3b8;
}

.preflight-subtotal-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #0f172a;
  background: #f8fafc;
  padding: 2px 8px;
  border-radius: 5px;
  border: 1px solid #e2e8f0;
  height: 26px;
  box-sizing: border-box;
}

.pf-subtotal-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.pf-subtotal-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #0f172a;
}

.estimate-created-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  height: 26px;
  box-sizing: border-box;
}

/* ── Sub-Header Meta Strip & Cells ── */
.preflight-meta-strip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  color: #475569;
  padding: 0 8px;
  background: #f8fafc;
  border-radius: 5px;
  margin: 0;
  border: 1px solid #cbd5e1;
  height: 26px;
  box-sizing: border-box;
  white-space: nowrap;
  line-height: 1.2;
}

.pf-meta-cell .preflight-meta-strip {
  margin: 0;
  max-width: 100%;
}

.pf-meta-sep {
  color: #94a3b8;
  font-size: 0.65rem;
  user-select: none;
  margin: 0 1px;
}

.pf-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pf-meta-item strong {
  color: #1e293b;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pf-meta-spec {
  color: #b45309;
}

.pf-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  font-size: 0.76rem;
}

.preflight-history-banner {
  background: #fefce8;
  border: 1px solid #fef08a;
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 0.75rem;
  color: #854d0e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.btn-return-current {
  background: #eab308;
  color: #ffffff;
  border: none;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn-return-current:hover {
  opacity: 0.9;
}

/* ── Row 2: AI Reasoning Trace ("Worked for Xs" & Thought Process) ── */
.preflight-trace-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  margin: 2px 0 8px 0;
}

.preflight-trace-wrapper,
.preflight-active-trace {
  margin: 0;
  width: 100%;
}

.preflight-trace-wrapper .grok-trace,
.preflight-active-trace .grok-trace,
.rfq-preflight-container .grok-trace {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0;
}

.preflight-trace-wrapper .grok-trace-header,
.preflight-active-trace .grok-trace-header,
.rfq-preflight-container .grok-trace-header {
  align-self: flex-start;
  padding: 0 10px;
  height: 26px;
  box-sizing: border-box;
  border-radius: 5px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  font-size: 0.74rem;
  font-weight: 500;
  color: #475569;
}

.preflight-trace-wrapper .grok-trace-header:hover,
.preflight-active-trace .grok-trace-header:hover,
.rfq-preflight-container .grok-trace-header:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #1e293b;
}

.rfq-preflight-container .grok-trace-time {
  color: #475569;
  font-weight: 600;
}

.rfq-preflight-container .grok-trace-sub {
  color: #64748b;
}

/* Expanded AI thought process timeline (in normal document flow) */
.preflight-trace-wrapper .grok-trace:not(.collapsed) .grok-timeline,
.preflight-active-trace .grok-trace:not(.collapsed) .grok-timeline,
.rfq-preflight-container .grok-timeline {
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  margin-top: 6px;
  margin-bottom: 4px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  padding: 10px 14px;
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

body.theme-dark .preflight-trace-wrapper .grok-trace-header,
body.theme-dark .preflight-active-trace .grok-trace-header,
body.theme-dark .rfq-preflight-container .grok-trace-header {
  background: var(--ib-search-bg, #182235);
  border-color: var(--ib-search-border, #283548);
  color: var(--ib-text-secondary, #94a3b8);
}

body.theme-dark .preflight-trace-wrapper .grok-trace-header:hover,
body.theme-dark .preflight-active-trace .grok-trace-header:hover,
body.theme-dark .rfq-preflight-container .grok-trace-header:hover {
  background: #1e293b;
  border-color: #475569;
  color: var(--ib-text-primary, #f8fafc);
}

body.theme-dark .preflight-trace-wrapper .grok-trace:not(.collapsed) .grok-timeline,
body.theme-dark .preflight-active-trace .grok-trace:not(.collapsed) .grok-timeline,
body.theme-dark .rfq-preflight-container .grok-timeline {
  background: var(--ib-panel-bg, #182235);
  border-color: var(--ib-border, #283548);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  scrollbar-color: #334155 transparent;
}

.rfq-preflight-container .grok-timeline::-webkit-scrollbar {
  width: 5px;
}

.rfq-preflight-container .grok-timeline::-webkit-scrollbar-track {
  background: transparent;
}

.rfq-preflight-container .grok-timeline::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.rfq-preflight-container .grok-step-icon-wrap {
  background: #f8fafc;
  color: #64748b;
}

.rfq-preflight-container .grok-step.active .grok-step-icon-wrap {
  color: #0284c7;
}

.rfq-preflight-container .grok-step.error .grok-step-icon-wrap {
  color: #e11d48;
}

.rfq-preflight-container .grok-step::before {
  background: #cbd5e1;
}

.rfq-preflight-container .grok-step-title {
  color: #334155;
  font-size: 13px;
  line-height: 1.4;
}

.rfq-preflight-container .grok-step-header:hover .grok-step-title {
  color: #0f172a;
}

.rfq-preflight-container .grok-step.thought .grok-step-title {
  color: #475569;
  font-weight: 500;
}

.rfq-preflight-container .grok-pulse-ring {
  border-color: #0284c7;
}

.rfq-preflight-container .grok-step-detail {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  max-height: 180px;
}

.rfq-preflight-container .grok-detail-args {
  color: #334155;
}

.rfq-preflight-container .grok-detail-res {
  color: #0284c7;
  font-weight: 600;
}

.rfq-preflight-container .grok-detail-res.error {
  color: #e11d48;
}

/* ── Preflight Items Table (Clean B2B Ledger) ── */
.preflight-table-wrapper {
  overflow-x: auto;
  overflow-y: visible;
  max-height: none;
  margin: 6px 0 10px 0;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #ffffff;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f8fafc;
  -webkit-overflow-scrolling: touch;
}

.preflight-table-wrapper::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.preflight-table-wrapper::-webkit-scrollbar-track {
  background: #f8fafc;
}

.preflight-table-wrapper::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.preflight-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.preflight-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
}

.preflight-table th {
  background: #f8fafc;
  padding: 6px 10px;
  font-weight: 600;
  font-size: 0.7rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}

.preflight-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  vertical-align: middle;
}

.preflight-table tr:hover {
  background: #f8fafc;
}

.preflight-table tr:last-child td {
  border-bottom: none;
}

/* ── SKU Column & 2-Line Layout ── */
.pf-col-idx {
  font-weight: 600;
  color: #64748b;
  width: 32px;
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
}

.pf-sku-main-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.pf-product-desc {
  font-size: 0.74rem;
  color: #64748b;
  margin-top: 2px;
  line-height: 1.3;
  font-weight: 400;
  max-width: 440px;
}

.sku-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 240px;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  transition: all 0.15s ease;
  vertical-align: middle;
  box-sizing: border-box;
}

.sku-pill .sku-pill-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  min-width: 0;
}

.sku-pill.sku-special {
  max-width: 260px;
  background: #f8fafc;
  color: #1e293b;
  border-color: #cbd5e1;
  font-family: inherit;
  font-weight: 500;
  font-size: 0.78rem;
}

.sku-pill.pf-clickable-sku {
  cursor: pointer;
  user-select: none;
}

.sku-pill.pf-clickable-sku:hover {
  background: #e0f2fe;
  border-color: #38bdf8;
  color: #0369a1;
}

.pf-caret {
  font-size: 0.65rem;
  opacity: 0.6;
  margin-left: 3px;
}

/* ── Minimalist Tags & Pills ── */
.pf-tag {
  font-size: 0.66rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  display: inline-block;
  vertical-align: middle;
}

.pf-tag-inquiry {
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.pf-tag-special {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.pf-tag-rfq {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.pf-tag-benchmark {
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}

.pf-bundle-note {
  font-size: 0.72rem;
  color: #0369a1;
  margin-top: 3px;
  font-weight: 500;
}

/* ── Line Item Notes (Fishbowl Sync) ── */
.pf-sku-cell-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.pf-line-note-container {
  display: flex;
  align-items: center;
  max-width: 100%;
  min-width: 0;
}

.pf-line-note-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.72rem;
  color: #92400e;
  max-width: 100%;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.pf-line-note-pill.pf-editable-note {
  cursor: pointer;
}

.pf-line-note-pill.pf-editable-note:hover {
  background: #fef3c7;
  border-color: #f59e0b;
}

.pf-note-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
  padding: 0 4px;
  border-radius: 3px;
  line-height: 1.3;
  flex-shrink: 0;
}

.pf-note-text {
  font-family: inherit;
  font-weight: 500;
  line-height: 1.25;
  word-break: break-word;
}

.pf-btn-delete-note {
  background: none;
  border: none;
  padding: 0 2px;
  margin: 0;
  cursor: pointer;
  color: #b45309;
  opacity: 0.7;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.pf-btn-delete-note:hover {
  opacity: 1;
  color: #ef4444;
}

.pf-btn-add-note {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: transparent;
  border: 1px dashed #cbd5e1;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.68rem;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.3;
}

.pf-btn-add-note-plus {
  font-weight: 700;
  color: #3b82f6;
}

.pf-btn-add-note:hover {
  border-color: #3b82f6;
  color: #2563eb;
  background: #eff6ff;
}

.pf-line-note-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}

.pf-line-note-input {
  width: 260px;
  max-width: 100%;
  font-size: 0.74rem;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  outline: none;
  box-sizing: border-box;
}

.pf-line-note-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.pf-btn-note-save {
  padding: 2px 7px;
  background: #10b981;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  min-width: 24px;
  transition: background 0.15s ease;
}

.pf-btn-note-save:hover {
  background: #059669;
}

.pf-btn-note-cancel {
  padding: 2px 7px;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  min-width: 24px;
  transition: background 0.15s ease;
}

.pf-btn-note-cancel:hover {
  background: #e2e8f0;
  color: #334155;
}

/* ── Quantity & Rate Columns ── */
.pf-qty-cell-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.pf-qty-val-row {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pf-qty-uom {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 500;
}

/* ── Small Bundle / Packaging Indicator ── */
.pf-bundle-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.02em;
  transition: all 0.15s ease;
  line-height: 1.25;
}

.pf-bundle-pill.pf-bundle-full {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.pf-bundle-pill.pf-bundle-suggest {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.pf-bundle-pill.pf-bundle-partial {
  background: #f8fafc;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.pf-bundle-pill.pf-bundle-info {
  background: #f8fafc;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.pf-bundle-pill.pf-bundle-primary-full {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

/* ── Primary Bundle Breaker Alert & Quick Rounding ── */
.pf-bundle-breaker-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  margin-top: 2px;
}

.pf-bundle-breaker-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.67rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.02em;
  line-height: 1.25;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
  box-shadow: 0 1px 2px rgba(245, 158, 11, 0.08);
}

.pf-breaker-alert-icon {
  flex-shrink: 0;
  color: #d97706;
  fill: currentColor;
}

.pf-btn-round-bundle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.66rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid #fed7aa;
  background: #fff7ed;
  color: #c2410c;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.25;
}

.pf-btn-round-bundle:hover {
  background: #ffedd5;
  border-color: #fdba74;
  color: #9a3412;
  transform: translateY(-0.5px);
  box-shadow: 0 2px 4px rgba(234, 88, 12, 0.12);
}

.pf-btn-round-bundle:active {
  transform: translateY(0);
}

/* Row-level Bundle Breaker accent */
tr.pf-row-bundle-breaker {
  background-color: rgba(245, 158, 11, 0.035);
}

tr.pf-row-bundle-breaker td.pf-col-idx {
  border-left: 3px solid #f59e0b;
}

/* Toolbar Bundle Breaker Summary */
.preflight-breaker-summary-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pf-bundle-breaker-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
  letter-spacing: 0.01em;
}

.btn-round-all-bundles {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid #fdba74;
  background: #fff7ed;
  color: #c2410c;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-round-all-bundles:hover {
  background: #ffedd5;
  border-color: #fb923c;
  color: #9a3412;
  box-shadow: 0 2px 5px rgba(234, 88, 12, 0.15);
}

.pf-bar-breaker-tag {
  font-size: 0.68rem;
  font-weight: 700;
  color: #d97706;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

/* Dark Theme Overrides for Bundle Breaker */
body.theme-dark .pf-bundle-pill.pf-bundle-primary-full {
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.3);
}

body.theme-dark .pf-bundle-breaker-pill {
  background: rgba(245, 158, 11, 0.18);
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.4);
}

body.theme-dark .pf-breaker-alert-icon {
  color: #fbbf24;
}

body.theme-dark .pf-btn-round-bundle {
  background: rgba(234, 88, 12, 0.15);
  color: #fed7aa;
  border-color: rgba(234, 88, 12, 0.35);
}

body.theme-dark .pf-btn-round-bundle:hover {
  background: rgba(234, 88, 12, 0.25);
  color: #fff7ed;
  border-color: rgba(234, 88, 12, 0.55);
}

body.theme-dark tr.pf-row-bundle-breaker {
  background-color: rgba(245, 158, 11, 0.06);
}

body.theme-dark .pf-bundle-breaker-header-badge {
  background: rgba(245, 158, 11, 0.2);
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.45);
}

body.theme-dark .btn-round-all-bundles {
  background: rgba(234, 88, 12, 0.18);
  color: #fed7aa;
  border-color: rgba(234, 88, 12, 0.45);
}

body.theme-dark .btn-round-all-bundles:hover {
  background: rgba(234, 88, 12, 0.3);
  color: #ffffff;
  border-color: rgba(234, 88, 12, 0.65);
}

.pf-bundle-icon {
  flex-shrink: 0;
  opacity: 0.85;
}

.pf-packaging-note {
  font-size: 0.72rem;
  color: #475569;
  font-weight: 500;
  margin-top: 2px;
}

.pf-suggested-qty {
  font-size: 0.74rem;
  color: #0284c7;
  font-weight: 600;
  margin-top: 2px;
}

.pf-rate-cell {
  display: inline-flex;
  align-items: baseline;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pf-rate-uom {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 500;
}

/* ── Note Column (To the right of Stock Status) ── */
.preflight-table th.pf-th-note {
  min-width: 140px;
  max-width: 260px;
  color: #64748b;
}

.pf-col-note {
  min-width: 140px;
  max-width: 280px;
  vertical-align: middle;
}

.pf-note-empty {
  color: #94a3b8;
  font-weight: 400;
  font-size: 0.8rem;
  padding-left: 2px;
}

body.theme-dark .pf-note-empty {
  color: #64748b;
}

/* ── Total Column & Delete Row Action ── */
.preflight-table th.pf-th-total {
  text-align: right;
  padding-right: 42px;
}

.pf-col-total {
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
}

.pf-total-cell-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
}

.pf-total-amount {
  font-weight: 600;
  font-size: 0.82rem;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pf-btn-delete-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  margin: 0;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  outline: none;
  flex-shrink: 0;
  opacity: 0.45;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.preflight-table tr:hover .pf-btn-delete-row {
  opacity: 1;
  color: #64748b;
  background: #f1f5f9;
  border-color: #e2e8f0;
}

.pf-btn-delete-row:hover {
  opacity: 1 !important;
  color: #ef4444 !important;
  background: #fef2f2 !important;
  border-color: #fecaca !important;
  transform: scale(1.08);
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.15);
}

.pf-btn-delete-row:active {
  background: #fee2e2 !important;
  color: #dc2626 !important;
  border-color: #fca5a5 !important;
  transform: scale(0.92);
  box-shadow: none;
}

.pf-btn-delete-row:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
}

.pf-btn-delete-row svg {
  display: block;
  pointer-events: none;
}

/* ── Available Stock Column ── */
.preflight-table .col-available {
  white-space: nowrap;
}

.preflight-table.hide-avail-col .col-available {
  display: none !important;
}

.pf-avail-val {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-weight: 600;
  font-size: 0.82rem;
  color: #1e293b;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.avail-stock-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 1px 6px;
  border-radius: 4px;
  cursor: help;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: transform 0.1s ease;
}

.avail-stock-pill:hover {
  transform: translateY(-1px);
}

.avail-stock-pill.avail-full {
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.avail-stock-pill.avail-partial {
  color: #9a3412;
  background: #fff7ed;
  border: 1px solid #fed7aa;
}

.avail-stock-pill.avail-zero {
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.avail-stock-pill .avail-stock-num {
  font-family: inherit;
}

.avail-stock-pill .avail-stock-uom {
  font-size: 0.7rem;
  font-weight: 500;
  opacity: 0.8;
}

/* ── Stock Status Column with Dot Indicators ── */
.pf-stock-status-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stock-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.pf-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.stock-tag.in-stock,
.stock-tag.allocated {
  color: #166534;
  background: transparent;
  padding: 0;
}

.stock-tag.in-stock .pf-status-dot,
.stock-tag.allocated .pf-status-dot {
  background: #16a34a;
}

.stock-tag.partial-stock {
  color: #9a3412;
  background: transparent;
  border: none;
  padding: 0;
}

.stock-tag.partial-stock .pf-status-dot {
  background: #ea580c;
}

.stock-tag.powder-coat {
  color: #6b21a8;
  background: transparent;
  border: none;
  padding: 0;
}

.stock-tag.powder-coat .pf-status-dot {
  background: #9333ea;
}

.stock-tag.inbound {
  color: #0369a1;
  background: transparent;
  padding: 0;
}

.stock-tag.inbound .pf-status-dot {
  background: #0284c7;
}

.stock-tag.out-stock {
  color: #991b1b;
  background: transparent;
  padding: 0;
}

.stock-tag.out-stock .pf-status-dot {
  background: #dc2626;
}

.stock-tag.special-order {
  color: #991b1b;
  background: transparent;
  padding: 0;
}

.stock-tag.special-order .pf-status-dot {
  background: #e11d48;
}

.stock-tag.other-loc-stock {
  color: #4338ca;
  background: transparent;
  padding: 0;
}

.stock-tag.other-loc-stock .pf-status-dot {
  background: #6366f1;
}

.pf-stock-other-loc {
  color: #4f46e5;
  font-weight: 500;
}

.pf-other-loc-hint {
  font-size: 0.70rem;
  color: #6366f1;
  font-weight: 500;
  margin-top: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
}

.pf-other-loc-hint:hover {
  color: #4338ca;
  text-decoration: underline;
}

.pf-stock-subtext {
  font-size: 0.72rem;
  margin-top: 1px;
  line-height: 1.25;
}

.pf-stock-ready {
  color: #15803d;
  font-weight: 500;
}

.pf-stock-coat {
  color: #7e22ce;
  font-weight: 500;
}

.pf-stock-warning {
  color: #c2410c;
  font-weight: 500;
}

.pf-stock-info {
  color: #0284c7;
  font-weight: 500;
}

.pf-stock-special {
  color: #b91c1c;
  font-weight: 600;
}

.pf-stock-muted {
  color: #64748b;
}

/* ── Locked Order Banner (when Estimate or SO exists in Fishbowl) ── */
.pf-locked-order-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 4px 0 10px 0;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #0284c7;
  border-radius: 6px;
  font-size: 0.78rem;
  color: #334155;
  line-height: 1.4;
}

.pf-locked-order-banner.is-issued {
  border-left-color: #10b981;
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.pf-locked-order-banner .pf-lock-icon {
  flex-shrink: 0;
  color: #0284c7;
}

.pf-locked-order-banner.is-issued .pf-lock-icon {
  color: #10b981;
}

.pf-locked-order-banner .pf-lock-text {
  flex: 1;
}

.pf-locked-order-banner .pf-lock-text strong {
  font-weight: 600;
}

body.theme-dark .pf-locked-order-banner {
  background: #0f172a;
  border-color: #334155;
  border-left-color: #38bdf8;
  color: #94a3b8;
}

body.theme-dark .pf-locked-order-banner.is-issued {
  background: rgba(6, 78, 59, 0.2);
  border-color: #065f46;
  border-left-color: #34d399;
  color: #a7f3d0;
}

body.theme-dark .pf-locked-order-banner .pf-lock-icon {
  color: #38bdf8;
}

body.theme-dark .pf-locked-order-banner.is-issued .pf-lock-icon {
  color: #34d399;
}

/* ── Typeahead Popover (SKU & Customer) ── */
.cyborg-typeahead-popover {
  position: fixed;
  z-index: 99999;
  width: 340px;
  max-width: 92vw;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.18), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 8px;
  font-family: inherit;
  animation: popoverFadeIn 0.1s ease-out;
}

@keyframes popoverFadeIn {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.typeahead-search-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.82rem;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  outline: none;
  background: #f8fafc;
  color: #0f172a;
  box-sizing: border-box;
  margin-bottom: 6px;
}

.typeahead-search-input:focus {
  border-color: #0284c7;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.typeahead-results-list {
  max-height: 220px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.typeahead-result-item {
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #1e293b;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background 0.1s ease;
}

.typeahead-result-item:hover,
.typeahead-result-item.highlighted {
  background: #f0f9ff;
  color: #0369a1;
}

.typeahead-item-title {
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.typeahead-item-sku {
  font-family: 'JetBrains Mono', monospace;
  color: #0369a1;
}

.typeahead-item-price {
  font-size: 0.75rem;
  font-weight: 700;
  color: #059669;
  font-family: 'JetBrains Mono', monospace;
  margin-left: auto;
  margin-right: 8px;
}

body.theme-dark .typeahead-item-price {
  color: #34d399;
}

.typeahead-item-uom {
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 500;
}

.typeahead-item-desc {
  font-size: 0.72rem;
  color: #64748b;
  white-space: normal;
  line-height: 1.25;
}

.typeahead-empty-state {
  padding: 10px;
  font-size: 0.78rem;
  color: #94a3b8;
  text-align: center;
}

.pf-save-badge {
  font-size: 0.74rem;
  color: #16a34a;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s ease;
  margin-left: 6px;
}

.pf-save-badge.visible {
  opacity: 1;
}

/* ── Preflight Actions Bar (Option A: Clean Minimalist) ── */
.preflight-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.preflight-actions-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.preflight-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-generate-estimate {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 5px;
  background: #0284c7;
  color: #ffffff;
  border: 1px solid #0284c7;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.15s ease;
}

.btn-generate-estimate:hover:not(:disabled) {
  background: #0369a1;
  border-color: #0369a1;
  transform: translateY(-1px);
}

.btn-generate-estimate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-generate-estimate.estimate-created-btn {
  background: #16a34a !important;
  border-color: #16a34a !important;
  color: #ffffff !important;
  cursor: default;
  box-shadow: none;
  transform: none;
}

.btn-issue-so {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 5px;
  background: #059669;
  color: #ffffff;
  border: 1px solid #059669;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(5, 150, 105, 0.2);
  transition: all 0.15s ease;
}

.btn-issue-so:hover:not(:disabled) {
  background: #047857;
  border-color: #047857;
  transform: translateY(-1px);
}

.btn-issue-so:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-issue-so.so-issued-btn {
  background: #10b981 !important;
  border-color: #10b981 !important;
  color: #ffffff !important;
  cursor: default;
  box-shadow: none;
  transform: none;
}

.btn-insert-draft {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 5px;
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-insert-draft:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.btn-refresh-preflight {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-refresh-preflight:hover {
  background: #f8fafc;
  color: #1e293b;
  border-color: #94a3b8;
}

@media (max-width: 768px) {
  /* ── Preflight Container Mobile Spacing ── */
  .rfq-preflight-container {
    margin: 8px 10px;
    padding: 10px 12px;
    border-radius: 8px;
  }

  .rfq-preflight-container.inline-preflight-container {
    margin: 8px 4px;
    border-radius: 8px;
  }

  .pf-emoji {
    display: none !important;
  }

  /* ── Preflight Header Mobile Ergonomics: 2-Row Compact Header ── */
  .preflight-header {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px 8px !important;
    margin-bottom: 4px !important;
  }

  .preflight-header-left {
    display: contents !important;
  }

  .preflight-customer-chip {
    order: 1 !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    height: auto !important;
    min-height: auto !important;
    display: flex !important;
    align-items: baseline !important;
    gap: 4px !important;
    cursor: pointer !important;
  }

  .preflight-customer-chip .customer-chip-label {
    font-size: 0.70rem;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .preflight-customer-chip .customer-chip-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: #0f172a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pf-header-right,
  .preflight-header-right {
    order: 2 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-shrink: 0 !important;
    width: auto !important;
  }

  .pf-subtotal-group {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    gap: 1px !important;
    flex-shrink: 0 !important;
  }

  .pf-header-timestamp {
    font-size: 0.65rem !important;
    color: #64748b !important;
    line-height: 1 !important;
    letter-spacing: 0 !important;
    opacity: 0.85 !important;
  }

  body.theme-dark .pf-header-timestamp {
    color: #94a3b8 !important;
  }

  .preflight-subtotal-badge {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    height: auto !important;
    min-height: auto !important;
    display: inline-flex !important;
    align-items: baseline !important;
  }

  .preflight-subtotal-badge .pf-subtotal-label {
    display: none; /* Hide redundant "Subtotal:" on mobile */
  }

  .preflight-subtotal-badge .pf-subtotal-amount {
    font-size: 1.05rem;
    font-weight: 800;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
  }

  .btn-toggle-preflight-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 2px !important;
    height: auto !important;
    min-height: auto !important;
    font-size: 0.74rem;
    color: #64748b;
    font-weight: 500;
    cursor: pointer;
  }

  .estimate-created-badge {
    font-size: 0.72rem;
    padding: 0 4px;
    height: auto;
    border: none !important;
    background: transparent !important;
    color: #15803d !important;
    font-weight: 600;
    width: auto;
  }

  /* Row 2: Secondary Controls Toolbar (Text-First Metadata Line) */
  .preflight-secondary-controls {
    order: 3 !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px 10px !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    padding-top: 4px !important;
    border-top: 1px solid #f1f5f9 !important;
  }

  .preflight-trace-row {
    order: 4 !important;
    margin: 4px 0 6px 0 !important;
    width: 100% !important;
  }

  .preflight-trace-wrapper .grok-trace-header {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    min-height: auto !important;
    height: auto !important;
    color: #ea580c !important;
    font-size: 0.72rem !important;
    font-weight: 600 !important;
  }

  /* Text-Only Warehouse Toggle */
  .preflight-location-toggle-wrap {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
  }

  .btn-location-toggle {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    min-height: auto !important;
    height: auto !important;
    gap: 3px !important;
    font-size: 0.72rem !important;
    color: #475569 !important;
    cursor: pointer;
  }

  .btn-location-toggle .loc-toggle-text {
    display: none;
  }

  .btn-location-toggle .loc-toggle-text-mobile {
    display: inline;
    font-size: 0.72rem;
    color: #64748b;
    font-weight: 500;
  }

  .btn-location-toggle .loc-toggle-pill {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    font-weight: 700;
  }

  .btn-location-toggle .loc-toggle-pill.on {
    color: #0284c7 !important;
  }

  .btn-location-toggle .loc-toggle-pill.off {
    color: #94a3b8 !important;
  }

  /* Minimalist Sheet Picker */
  .preflight-sheet-picker {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    min-height: auto !important;
    height: auto !important;
    gap: 3px !important;
  }

  .preflight-sheet-picker .sheet-control-label {
    display: none;
  }

  .preflight-sheet-select {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    font-size: 0.72rem !important;
    font-weight: 600 !important;
    color: #0f172a !important;
    padding: 0 !important;
    max-width: 100px !important;
    cursor: pointer;
  }


  /* Text-Only Run Switcher */
  .preflight-history-select,
  .preflight-run-pill {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    height: auto !important;
    min-height: auto !important;
    font-size: 0.72rem !important;
    color: #64748b !important;
    font-weight: 600 !important;
  }

  .preflight-breaker-summary-wrap {
    width: auto;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 0;
  }

  .pf-bundle-breaker-header-badge {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    height: auto !important;
    min-height: auto !important;
    font-size: 0.72rem !important;
    color: #b45309 !important;
    font-weight: 600 !important;
  }

  .btn-round-all-bundles {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 4px !important;
    height: auto !important;
    min-height: auto !important;
    font-size: 0.70rem !important;
    color: #0284c7 !important;
    font-weight: 600 !important;
  }

  /* Metadata Info Toggle Button & Drawer on Mobile */
  .btn-toggle-meta-mobile {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    height: auto !important;
    min-height: auto !important;
    font-size: 0.72rem !important;
    color: #64748b !important;
    font-weight: 500 !important;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
  }

  .btn-toggle-meta-mobile:hover,
  .btn-toggle-meta-mobile:active {
    color: #1e293b !important;
  }

  .pf-meta-cell {
    display: none;
    width: 100%;
    flex-basis: 100%;
    order: 11;
    margin-top: 4px;
  }

  .pf-meta-cell.mobile-open {
    display: block;
  }

  .pf-meta-cell .preflight-meta-strip {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    font-size: 0.72rem;
    height: auto;
    white-space: normal;
    flex-wrap: wrap;
    border-radius: 5px;
    background: #f1f5f9;
  }

  .pf-meta-item {
    word-break: break-word;
  }

  /* Expanded Trace on Mobile */
  .preflight-trace-wrapper.trace-open,
  .preflight-trace-wrapper:has(.grok-trace:not(.collapsed)),
  .preflight-trace-row:has(.grok-trace:not(.collapsed)) {
    flex-basis: 100%;
    width: 100%;
  }

  .preflight-trace-wrapper .grok-trace:not(.collapsed) .grok-timeline {
    width: 100%;
    max-height: 220px;
    padding: 10px 10px;
    margin-top: 6px;
    border-radius: 6px;
  }

  .rfq-preflight-container .grok-step {
    padding-left: 24px;
    padding-bottom: 8px;
    font-size: 0.75rem;
  }

  .rfq-preflight-container .grok-step::before {
    left: 8px;
  }

  .rfq-preflight-container .grok-step-icon-wrap {
    width: 18px;
    height: 18px;
  }

  .rfq-preflight-container .grok-step-icon-wrap svg {
    width: 12px;
    height: 12px;
  }

  .rfq-preflight-container .grok-step-title {
    font-size: 0.76rem;
    line-height: 1.35;
    word-break: break-word;
  }

  .rfq-preflight-container .grok-step-detail {
    max-height: 160px;
    font-size: 0.72rem;
    padding: 6px 8px;
    word-break: break-all;
  }

  /* ── Mobile Preflight Cards (Table Transformation) ── */
  .preflight-table-wrapper {
    overflow-x: hidden;
    overflow-y: visible;
    max-height: none;
    margin: 6px 0;
    border: none;
    background: transparent;
    padding: 0;
  }

  .preflight-table {
    display: flex;
    flex-direction: column;
    width: 100%;
    border-collapse: separate;
  }

  .preflight-table thead {
    display: none !important;
  }

  .preflight-table tbody {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .preflight-table tr:not(.preflight-section-header-row) {
    display: grid !important;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "sku   total"
      "rate  qty"
      "stock stock"
      "note  note";
    gap: 6px 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
    width: 100%;
    position: relative;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }

  .preflight-table tr:not(.preflight-section-header-row):hover {
    background: #ffffff;
  }

  .preflight-table tr:not(.preflight-section-header-row):active {
    background: #f8fafc;
  }

  .preflight-table td {
    padding: 0 !important;
    border: none !important;
  }

  .pf-col-idx {
    display: none !important;
  }

  /* SKU in Top Left of Card */
  .pf-col-sku {
    grid-area: sku;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
  }

  /* Note in its own full-width area across mobile card */
  .pf-col-note {
    grid-area: note;
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
  }

  .pf-col-note.pf-col-note-empty {
    display: none !important;
  }

  .pf-line-note-container {
    width: 100%;
    margin-top: 2px;
  }

  .pf-line-note-pill {
    font-size: 0.76rem;
    padding: 3px 8px;
    width: 100%;
    box-sizing: border-box;
  }

  .pf-btn-add-note {
    font-size: 0.74rem;
    padding: 3px 8px;
    min-height: 28px;
    touch-action: manipulation;
  }

  .pf-line-note-input-wrap {
    width: 100%;
    display: flex;
    gap: 4px;
  }

  .pf-line-note-input {
    flex: 1;
    min-width: 0;
    min-height: 32px;
    font-size: 0.8rem;
    padding: 4px 8px;
    touch-action: manipulation;
  }

  .pf-btn-note-save,
  .pf-btn-note-cancel {
    min-height: 32px;
    min-width: 32px;
    font-size: 0.85rem;
    touch-action: manipulation;
  }

  .pf-col-sku .sku-pill {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    touch-action: manipulation;
    max-width: 100%;
  }

  .pf-product-desc {
    max-width: 100%;
  }

  /* Total in Top Right of Card */
  .pf-col-total {
    grid-area: total;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    text-align: right;
  }

  .pf-total-cell-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    width: auto;
  }

  .pf-total-amount {
    font-size: 0.94rem;
    font-weight: 700;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
  }

  .pf-btn-delete-row {
    opacity: 1 !important;
    width: auto !important;
    height: auto !important;
    min-width: 22px !important;
    min-height: 22px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    color: #94a3b8 !important;
    font-size: 1.1rem !important;
    line-height: 1 !important;
    touch-action: manipulation;
  }

  .pf-btn-delete-row:active {
    color: #ef4444 !important;
  }

  /* Quantity & Rate in Clean Second Row */
  .pf-col-qty {
    grid-area: qty;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.84rem;
    min-width: 0;
  }

  .pf-col-rate {
    grid-area: rate;
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 4px;
    font-size: 0.84rem;
    text-align: right;
    min-width: 0;
  }

  /* Click-to-Edit: Subtle Dotted Underline instead of bulky box */
  .pf-editable-num {
    display: inline !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    font-weight: 600 !important;
    min-height: auto !important;
    color: #0f172a !important;
    border-bottom: 1px dotted #cbd5e1 !important;
    touch-action: manipulation;
  }

  .pf-editable-num:active {
    background: transparent !important;
    color: #0284c7 !important;
    border-bottom-color: #0284c7 !important;
  }

  .pf-bundle-pill {
    display: inline-flex !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    font-size: 0.74rem !important;
    font-weight: 500 !important;
    color: #15803d !important;
  }

  .pf-bundle-icon {
    display: none !important;
  }

  .pf-compact-input {
    font-size: 16px !important; /* Prevents iOS auto-zoom on input focus */
    min-height: 30px;
    padding: 2px 6px;
    border-radius: 4px;
  }

  .pf-compact-input.pf-qty-input {
    width: 75px;
  }

  .pf-compact-input.pf-price-input {
    width: 85px;
  }

  /* Stock Status Badge & Lead Time Row */
  .pf-col-stock {
    grid-area: stock;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 4px !important;
    border-top: 1px dashed #f1f5f9 !important;
  }

  .stock-tag {
    font-size: 0.74rem;
  }

  /* Section Header Divider on Mobile */
  .preflight-table .preflight-section-header-row {
    display: block !important;
    margin: 4px 0 2px 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  .preflight-table .preflight-section-header-row td {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
    border-radius: 5px !important;
    padding: 6px 10px !important;
    font-size: 0.72rem;
  }

  /* ── Preflight Actions Bar Mobile Ergonomics ── */
  .preflight-actions-bar {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin-top: 10px;
    padding-top: 10px;
    width: 100%;
    box-sizing: border-box;
  }

  .preflight-actions-left {
    display: contents !important;
  }

  .preflight-actions-right {
    display: contents !important;
  }

  .btn-generate-estimate,
  .btn-issue-so,
  .btn-view-estimate-pdf {
    width: 100% !important;
    min-height: 40px !important;
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    justify-content: center !important;
    border-radius: 6px !important;
    touch-action: manipulation !important;
    box-sizing: border-box !important;
  }

  .btn-insert-draft,
  .btn-refresh-preflight {
    flex: 1 1 0 !important;
    width: auto !important;
    min-height: 38px !important;
    font-size: 0.82rem !important;
    justify-content: center !important;
    padding: 6px !important;
    border-radius: 6px !important;
    white-space: nowrap !important;
    touch-action: manipulation !important;
    box-sizing: border-box !important;
  }

  /* ── Mobile Popover Typeahead Ergonomics ── */
  .cyborg-typeahead-popover {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: none !important;
    box-sizing: border-box;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  }

  .typeahead-search-input {
    font-size: 16px !important; /* Prevents iOS auto-zoom on input focus */
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 6px;
    box-sizing: border-box;
  }

  .typeahead-result-item {
    padding: 10px 12px;
    min-height: 44px;
    box-sizing: border-box;
    font-size: 0.88rem;
  }
}

/* ==========================================================================
   MOBILE-FIRST ENHANCEMENTS (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
  /* ── App Topbar Mobile Ergonomics ── */
  .app-topbar {
    padding: 0 10px;
    height: 52px;
    min-height: 52px;
    gap: 8px;
  }

  .topbar-brand {
    min-width: auto;
    gap: 6px;
  }

  .brand-logo {
    width: 26px;
    height: 26px;
  }

  .brand-title {
    font-size: 0.95rem;
    letter-spacing: 0.02em;
  }

  .brand-badge {
    display: none;
  }

  .topbar-search-wrapper {
    max-width: none;
    flex: 1;
    min-width: 0;
  }

  .search-input-box {
    padding: 5px 8px;
    gap: 6px;
    border-radius: 6px;
  }

  .search-icon {
    font-size: 0.8rem;
  }

  .search-input {
    font-size: 16px; /* Prevents iOS auto-zoom on input focus */
  }

  .search-filter-dropdown {
    position: fixed;
    top: 56px;
    left: 8px;
    right: 8px;
    max-width: none;
    border-radius: 8px;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
  }

  .search-filter-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .search-filter-row label {
    text-align: left;
  }

  .search-filter-checkbox-row {
    padding-left: 0;
  }

  .topbar-actions {
    gap: 4px;
    flex-shrink: 0;
  }

  .topbar-action-btn {
    padding: 6px 8px;
    min-width: 34px;
    height: 34px;
    justify-content: center;
    border-radius: 6px;
  }

  .topbar-action-btn .btn-text {
    display: none;
  }

  .topbar-action-btn .btn-icon {
    font-size: 1rem;
    margin: 0;
  }

  /* ── Inbox Toolbar Panel ── */
  .inbox-toolbar-panel {
    padding: 8px 10px 6px 10px;
    gap: 8px;
  }

  .inbox-tabs-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .dev-queue-sim {
    width: 100%;
    box-sizing: border-box;
    justify-content: space-between;
    padding: 5px 10px;
    border-radius: 12px;
  }

  .dev-queue-sim .sim-select-wrap {
    flex: 1;
    margin: 0 4px;
  }

  .dev-queue-sim .sim-select {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
  }

  .inbox-tabs {
    width: 100%;
    background: var(--ib-mobile-tabs-bg, #f1f5f9);
    border-radius: 8px;
    padding: 3px;
    gap: 4px;
    transition: background-color 0.2s ease;
  }

  .inbox-tab {
    flex: 1;
    justify-content: center;
    padding: 7px 10px;
    font-size: 0.82rem;
    border-radius: 6px;
    border-bottom: none;
    text-align: center;
  }

  .inbox-tab.active {
    background: var(--ib-mobile-tab-active-bg, #ffffff);
    color: var(--ib-mobile-tab-active-color, #0284c7);
    box-shadow: var(--ib-mobile-tab-active-shadow, 0 1px 3px rgba(0, 0, 0, 0.08));
  }

  .inbox-category-pills {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 2px 0 6px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .inbox-category-pills::-webkit-scrollbar {
    display: none;
  }

  .category-pill {
    padding: 5px 12px;
    font-size: 0.78rem;
    flex-shrink: 0;
  }

  /* ── Action Subbar ── */
  .inbox-subbar {
    padding: 6px 10px;
    font-size: 0.76rem;
  }

  .subbar-left {
    gap: 8px;
  }

  .subbar-right {
    gap: 4px;
  }

  .inbox-count-text {
    font-size: 0.74rem;
  }

  .page-nav-btn {
    padding: 4px 8px;
    font-size: 1.1rem;
  }

  /* ── Native Mobile Email Card Rows (Clean 3-Tier Layout) ── */
  .inbox-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "senders date star"
      "content content content";
    padding: 12px 14px 12px 12px;
    gap: 4px 8px;
    align-items: baseline;
    min-height: 82px;
    border-bottom: 1px solid var(--ib-row-border, #f1f5f9);
    background: var(--ib-row-bg, #ffffff);
    border-left: 3px solid transparent;
    transition: background-color 0.15s ease, border-left-color 0.15s ease;
  }

  .inbox-row:active {
    background: var(--ib-row-hover-bg, #f1f5f9);
  }

  .inbox-row.unread {
    background: var(--ib-row-unread-bg, #f0f7ff);
    border-left-color: var(--ib-row-unread-accent, #0284c7);
  }

  .inbox-row.unread .row-senders {
    font-weight: 700;
    color: var(--ib-text-primary, #0f172a);
  }

  .inbox-row.unread .row-subject {
    font-weight: 600;
    color: var(--ib-text-primary, #0f172a);
  }

  .row-select {
    display: none;
  }

  .row-senders {
    grid-area: senders;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    font-size: 0.94rem;
    font-weight: 600;
    color: var(--ib-row-senders-color, #334155);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .row-date {
    grid-area: date;
    font-size: 0.74rem;
    color: var(--ib-row-date-color, #64748b);
    white-space: nowrap;
    text-align: right;
    min-width: auto;
  }

  .row-star {
    grid-area: star;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .star-btn {
    font-size: 1.2rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    touch-action: manipulation;
  }

  .row-content {
    grid-area: content;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
    min-width: 0;
    overflow: visible;
  }

  .row-separator {
    display: none;
  }

  .row-subject {
    width: 100%;
    max-width: 100%;
    white-space: normal;
    font-size: 0.88rem;
    line-height: 1.35;
    color: var(--ib-row-subject-color, #334155);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .row-snippet {
    width: 100%;
    max-width: 100%;
    white-space: normal;
    font-size: 0.8rem;
    line-height: 1.35;
    color: var(--ib-row-snippet-color, #64748b);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 1px;
  }

  .inbox-row-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
    width: 100%;
  }

  .inbox-att-chip {
    padding: 3px 8px;
    font-size: 0.72rem;
    border-radius: 12px;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .inbox-cyborg-badge {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--ib-brand-title, #0284c7);
    background: var(--ib-brand-badge-bg, #e0f2fe);
    border: 1px solid var(--ib-brand-badge-border, #bae6fd);
    padding: 1px 6px;
    border-radius: 4px;
    margin-right: 4px;
    display: inline-block;
  }

  .row-actions {
    display: none !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   WINGMAN TEAMMATE DEBRIEF & DELTA ORDER DIFF STYLES
   ══════════════════════════════════════════════════════════════════════ */
.pf-wingman-briefing {
  margin: 8px 0 12px 0;
  padding: 10px 14px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25), 0 0 12px rgba(56, 189, 248, 0.08);
  color: #f8fafc;
}

.pf-wingman-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.pf-wingman-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 1px 7px;
  border-radius: 4px;
}

.pf-intent-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pf-intent-mutation {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.pf-intent-inquiry {
  background: rgba(14, 165, 233, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.4);
}

.pf-intent-approval {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.pf-intent-metadata {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

.pf-intent-no_action {
  background: rgba(148, 163, 184, 0.2);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.pf-net-delta-badge {
  margin-left: auto;
  font-size: 0.76rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 1px 8px;
  border-radius: 4px;
}

.pf-net-delta-badge.net-plus {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.pf-net-delta-badge.net-minus {
  background: rgba(244, 63, 94, 0.2);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.pf-wingman-body {
  font-size: 0.84rem;
  line-height: 1.45;
  color: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin-bottom: 8px;
}

.pf-wingman-body strong {
  color: #38bdf8;
}

/* Diff Chips for Added / Removed / Updated Items */
.pf-delta-diff-strip {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.pf-diff-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  flex-wrap: wrap;
}

.pf-diff-action-tag {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.pf-diff-action-add {
  background: #166534;
  color: #86efac;
}

.pf-diff-action-remove {
  background: #991b1b;
  color: #fca5a5;
}

.pf-diff-action-update {
  background: #92400e;
  color: #fde68a;
}

.pf-diff-item-desc {
  font-weight: 600;
  color: #f1f5f9;
}

.pf-diff-item-amt {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.pf-diff-item-amt.plus {
  color: #4ade80;
}

.pf-diff-item-amt.minus {
  color: #fb7185;
}

/* Master Order Toggle Button */
.pf-master-order-toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 6px 0;
  padding: 4px 0;
}

.btn-toggle-master-ledger {
  background: transparent;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 0.76rem;
  font-weight: 600;
  color: #475569;
  padding: 4px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-toggle-master-ledger:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

/* ── Connect Google to Reply Modal ── */
.connect-google-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.connect-google-card {
  position: relative;
  z-index: 100000;
  width: 100%;
  max-width: 480px;
  background: #0f1523;
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 14px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85), 0 0 30px rgba(56, 189, 248, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.connect-google-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #1e293b;
  background: #131b2e;
}

.connect-google-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.connect-google-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}

.connect-google-header h3 {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: #f1f5f9;
  margin: 0;
}

.connect-google-body {
  padding: 24px 22px 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.connect-google-hero-badge {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.connect-google-badge-glow {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

.connect-google-badge-icon {
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
}

.connect-google-title {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 700;
  color: #f8fafc;
  margin: 0 0 8px 0;
}

.connect-google-desc {
  font-family: var(--font-sans);
  font-size: 0.86rem;
  line-height: 1.5;
  color: #94a3b8;
  margin: 0 0 16px 0;
}

.connect-google-desc strong {
  color: #f1f5f9;
}

.connect-google-callout {
  width: 100%;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(71, 85, 105, 0.4);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  box-sizing: border-box;
}

.connect-google-callout .callout-icon {
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1.3;
}

.connect-google-callout .callout-content {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.45;
}

.connect-google-draft-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  color: #4ade80;
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
}

.draft-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px #4ade80;
  flex-shrink: 0;
}

.connect-google-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid #1e293b;
  background: #0f1523;
}

.btn-cancel-modal {
  background: transparent;
  border: 1px solid #334155;
  color: #94a3b8;
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-cancel-modal:hover {
  background: #1e293b;
  color: #f1f5f9;
  border-color: #475569;
}

.btn-connect-google {
  background: #ffffff;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: all 0.15s ease;
}

.btn-connect-google:hover {
  background: #f8fafc;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.btn-connect-google:active {
  transform: translateY(0);
}

.btn-connect-google:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

body.theme-light .connect-google-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.2), 0 0 20px rgba(2, 132, 199, 0.08);
}

body.theme-light .connect-google-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

body.theme-light .connect-google-header h3 {
  color: #0f172a;
}

body.theme-light .connect-google-title {
  color: #0f172a;
}

body.theme-light .connect-google-desc {
  color: #475569;
}

body.theme-light .connect-google-desc strong {
  color: #0f172a;
}

body.theme-light .connect-google-callout {
  background: #f0f9ff;
  border-color: #bae6fd;
}

body.theme-light .connect-google-callout .callout-content {
  color: #0369a1;
}

body.theme-light .connect-google-footer {
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

body.theme-light .btn-cancel-modal {
  border-color: #cbd5e1;
  color: #475569;
}

body.theme-light .btn-cancel-modal:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

/* Floating General Toast */
.inbox-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
  padding: 9px 20px;
  border-radius: 24px;
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 500;
  z-index: 100000;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.inbox-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* Mobile Responsiveness for Modal */
@media (max-width: 600px) {
  .connect-google-modal {
    padding: 10px;
  }
  .connect-google-card {
    max-width: 100%;
  }
  .connect-google-footer {
    flex-direction: column-reverse;
    gap: 8px;
  }
  .btn-cancel-modal,
  .btn-connect-google {
    width: 100%;
    justify-content: center;
    padding: 10px;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   CYBORG TERMINAL RIGHT PANEL & FULLSCREEN SYSTEM
   ══════════════════════════════════════════════════════════════════════ */

/* Active indicator on topbar Terminal button when terminal is open */
.topbar-action-btn.view-switch-btn.active {
  background: rgba(56, 189, 248, 0.18) !important;
  border-color: rgba(56, 189, 248, 0.6) !important;
  color: #38bdf8 !important;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.28) !important;
}

body.theme-light .topbar-action-btn.view-switch-btn.active {
  background: rgba(2, 132, 199, 0.12) !important;
  border-color: #0284c7 !important;
  color: #0284c7 !important;
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.22) !important;
}

/* Terminal Resizer Bar (Draggable divider on the left edge of panel) */
.terminal-resizer {
  width: 5px;
  background: var(--term-border, #1e293b);
  cursor: col-resize;
  transition: background 0.15s ease;
  z-index: 25;
  flex-shrink: 0;
  height: 100%;
  position: relative;
}

body.theme-light .terminal-resizer {
  background: #e2e8f0;
}

.terminal-resizer:hover,
.terminal-resizer.dragging {
  background: var(--cli-cyan, #38bdf8);
}

/* Base Terminal View Section */
.terminal-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background: var(--term-bg, #090d16);
  border-left: 1px solid var(--term-border, #1e293b);
  overflow: hidden;
  z-index: 20;
}

body.theme-light .terminal-view {
  background: #f8fafc;
  border-left-color: #e2e8f0;
}

/* 1. Right Panel Mode (Default initial open state) */
.terminal-view.panel-mode {
  flex: 0 0 540px;
  width: 540px;
  min-width: 360px;
  max-width: 80%;
  box-shadow: -6px 0 28px rgba(0, 0, 0, 0.35);
}

body.theme-light .terminal-view.panel-mode {
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.08);
}

/* 2. Fullscreen Mode */
.terminal-view.fullscreen-mode {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  flex: 1 1 100% !important;
  border-left: none !important;
  box-shadow: none !important;
  z-index: 60;
}

/* Terminal Panel Header Bar */
.terminal-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  min-height: 44px;
  max-height: 44px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--term-border, #1e293b);
  backdrop-filter: blur(12px);
  z-index: 30;
  flex-shrink: 0;
  gap: 12px;
}

body.theme-light .terminal-panel-header {
  background: #ffffff;
  border-bottom-color: #e2e8f0;
}

.terminal-panel-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}

.terminal-panel-logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.45));
}

.terminal-panel-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-panel-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: #f8fafc;
  white-space: nowrap;
}

body.theme-light .terminal-panel-title {
  color: #0f172a;
}

.terminal-panel-badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  color: var(--cli-cyan, #38bdf8);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

body.theme-light .terminal-panel-badge {
  color: #0284c7;
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.2);
}

.terminal-panel-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.terminal-panel-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 6px;
  color: #cbd5e1;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

body.theme-light .terminal-panel-action-btn {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}

.terminal-panel-action-btn:hover {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.6);
  color: #38bdf8;
  transform: translateY(-1px);
}

body.theme-light .terminal-panel-action-btn:hover {
  background: #e2e8f0;
  border-color: #0284c7;
  color: #0284c7;
}

.terminal-panel-action-btn.close-btn {
  padding: 5px 8px;
}

.terminal-panel-action-btn.close-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.5);
  color: #f87171;
}

body.theme-light .terminal-panel-action-btn.close-btn:hover {
  background: #fee2e2;
  border-color: #ef4444;
  color: #ef4444;
}

.terminal-panel-action-btn svg {
  flex-shrink: 0;
}

/* Canvas Pane overlay behavior when Copilot is docked in panel mode */
.terminal-view.panel-mode .canvas-pane:not(.collapsed) {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  z-index: 50;
}

/* Terminal Body Wrapper (Contains terminal-pane and canvas-pane) */
.terminal-body-wrapper {
  display: flex;
  flex-direction: row;
  flex: 1 1 auto;
  height: calc(100% - 44px);
  width: 100%;
  overflow: hidden;
  position: relative;
}

.terminal-body-wrapper .terminal-pane {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  height: 100% !important;
  max-height: 100% !important;
  background: var(--term-bg, #090d16);
  overflow: hidden;
  position: relative;
  width: 100%;
  min-width: 0;
}

body.theme-light .terminal-body-wrapper .terminal-pane {
  background: #f8fafc;
}

/* Right Panel Mode Hero Optimizations (High-density proportional fit) */
.terminal-view.panel-mode .terminal-hero {
  padding: 18px 14px;
}

.terminal-view.panel-mode .hero-logo-container {
  margin-bottom: 14px;
}

.terminal-view.panel-mode .hero-logo-glow {
  width: 140px;
  max-width: 50vw;
}

.terminal-view.panel-mode .hero-brand-title {
  font-size: 15px;
  letter-spacing: 2px;
}

.terminal-view.panel-mode .hero-brand-subtitle {
  font-size: 9.5px;
  letter-spacing: 1.2px;
  margin-top: 2px;
}

.terminal-view.panel-mode .cyber-chips-container {
  gap: 6px;
  margin-bottom: 14px;
  padding: 0 4px;
}

.terminal-view.panel-mode .cyber-chip {
  padding: 3px 8px;
  border-radius: 12px;
}

.terminal-view.panel-mode .cyber-chip-name {
  font-size: 10px;
}

.terminal-view.panel-mode .cyber-chip-icon {
  font-size: 11px;
}

.terminal-view.panel-mode .terminal-stream {
  padding: 16px 16px 12px;
  gap: 12px;
}

.terminal-view.panel-mode .docked-input-bar {
  padding: 8px 12px max(10px, env(safe-area-inset-bottom));
}

/* Light theme terminal contrast overrides inside inbox container */
body.theme-light .terminal-view .hero-brand-title,
:root[data-theme="light"] .terminal-view .hero-brand-title {
  color: #0f172a !important;
  text-shadow: none !important;
}

body.theme-light .terminal-view .hero-brand-subtitle,
:root[data-theme="light"] .terminal-view .hero-brand-subtitle {
  color: #0284c7 !important;
}

body.theme-light .terminal-view .hero-unauth-msg,
:root[data-theme="light"] .terminal-view .hero-unauth-msg {
  color: #334155 !important;
}

body.theme-light .terminal-view .cyber-chip,
:root[data-theme="light"] .terminal-view .cyber-chip {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}

body.theme-light .terminal-view .cyber-chip-name,
:root[data-theme="light"] .terminal-view .cyber-chip-name {
  color: #0f172a !important;
}

body.theme-light .terminal-view .hero-input-box,
:root[data-theme="light"] .terminal-view .hero-input-box {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}

body.theme-light .terminal-view .docked-input-bar,
:root[data-theme="light"] .terminal-view .docked-input-bar {
  background: #ffffff !important;
  border-top-color: #e2e8f0 !important;
}

body.theme-light .terminal-view .cli-textarea,
:root[data-theme="light"] .terminal-view .cli-textarea {
  color: #0f172a !important;
}

body.theme-light .terminal-view .cli-textarea::placeholder,
:root[data-theme="light"] .terminal-view .cli-textarea::placeholder {
  color: #64748b !important;
}

body.theme-light .terminal-view .cli-user-row,
:root[data-theme="light"] .terminal-view .cli-user-row,
body.theme-light .terminal-view .cli-prompt-text,
:root[data-theme="light"] .terminal-view .cli-prompt-text {
  color: #0f172a !important;
}

body.theme-light .terminal-view .cli-body-markdown,
:root[data-theme="light"] .terminal-view .cli-body-markdown,
body.theme-light .terminal-view .markdown-body,
:root[data-theme="light"] .terminal-view .markdown-body {
  color: #0f172a !important;
}

body.theme-light .terminal-view .markdown-body p,
:root[data-theme="light"] .terminal-view .markdown-body p,
body.theme-light .terminal-view .markdown-body li,
:root[data-theme="light"] .terminal-view .markdown-body li,
body.theme-light .terminal-view .markdown-body span,
:root[data-theme="light"] .terminal-view .markdown-body span {
  color: #1e293b !important;
}

body.theme-light .terminal-view .markdown-body h1,
:root[data-theme="light"] .terminal-view .markdown-body h1,
body.theme-light .terminal-view .markdown-body h2,
:root[data-theme="light"] .terminal-view .markdown-body h2,
body.theme-light .terminal-view .markdown-body h3,
:root[data-theme="light"] .terminal-view .markdown-body h3,
body.theme-light .terminal-view .markdown-body strong,
:root[data-theme="light"] .terminal-view .markdown-body strong {
  color: #0f172a !important;
}

/* Mobile Responsiveness for Terminal Panel (< 768px) */
@media (max-width: 768px) {
  .terminal-view.panel-mode {
    position: absolute;
    inset: 0;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 100% !important;
    border-left: none !important;
    box-shadow: none !important;
    z-index: 60;
  }

  .terminal-resizer {
    display: none !important;
  }

  .terminal-panel-btn-text {
    display: none;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   IN-PLACE CYBORG LOGIN MODAL & AUTH STATUS STYLING
   ══════════════════════════════════════════════════════════════════════ */

/* Topbar User Auth Button */
.topbar-action-btn.user-auth-btn {
  border-color: rgba(56, 189, 248, 0.3);
  color: var(--ib-btn-color, #cbd5e1);
  transition: all 0.2s ease;
}

.topbar-action-btn.user-auth-btn:hover {
  border-color: rgba(56, 189, 248, 0.6);
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
}

body.unauthenticated .topbar-action-btn.user-auth-btn {
  background: rgba(56, 189, 248, 0.15) !important;
  border-color: #38bdf8 !important;
  color: #38bdf8 !important;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3) !important;
  animation: pulseAuthBtn 2.5s infinite;
}

@keyframes pulseAuthBtn {
  0%, 100% { box-shadow: 0 0 8px rgba(56, 189, 248, 0.25); }
  50% { box-shadow: 0 0 16px rgba(56, 189, 248, 0.5); }
}

body.theme-light .topbar-action-btn.user-auth-btn {
  border-color: #cbd5e1;
  color: #334155;
}

body.theme-light.unauthenticated .topbar-action-btn.user-auth-btn {
  background: rgba(2, 132, 199, 0.1) !important;
  border-color: #0284c7 !important;
  color: #0284c7 !important;
}

/* Hero Unauthenticated Callout */
.hero-unauth-actions {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: modalScaleIn 0.3s ease;
}

body.unauthenticated .hero-unauth-actions {
  display: flex !important;
}

.hero-unauth-msg {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--term-dim, #94a3b8);
  letter-spacing: 0.5px;
}

.hero-signin-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border: 1px solid rgba(56, 189, 248, 0.5);
  border-radius: 8px;
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.35);
  transition: all 0.2s ease;
}

.hero-signin-btn:hover {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(2, 132, 199, 0.5);
}

.hero-signin-btn:active {
  transform: translateY(0);
}

/* Login Modal Container */
.cyborg-login-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.cyborg-login-modal .modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100001;
  animation: fadeIn 0.2s ease;
}

.cyborg-login-card {
  position: relative;
  z-index: 100002;
  width: 100%;
  max-width: 440px;
  background: #0f1523;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 16px;
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.85), 0 0 35px rgba(56, 189, 248, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

body.theme-light .cyborg-login-card {
  background: #ffffff;
  border-color: rgba(2, 132, 199, 0.3);
  box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.18), 0 0 30px rgba(2, 132, 199, 0.12);
}

.cyborg-login-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(56, 189, 248, 0.15);
  background: #131b2e;
}

body.theme-light .cyborg-login-header {
  background: #f8fafc;
  border-bottom-color: #e2e8f0;
}

.cyborg-login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cyborg-login-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.45));
}

.cyborg-login-brand-text {
  display: flex;
  flex-direction: column;
}

.cyborg-login-brand-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #f8fafc;
}

body.theme-light .cyborg-login-brand-title {
  color: #0f172a;
}

.cyborg-login-brand-subtitle {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--cli-cyan, #38bdf8);
}

body.theme-light .cyborg-login-brand-subtitle {
  color: #0284c7;
}

.cyborg-login-body {
  padding: 24px 22px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Status Context Badge */
.cyborg-login-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 20px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  width: fit-content;
}

.cyborg-login-status-badge.badge-expired {
  background: rgba(250, 204, 21, 0.1);
  border-color: rgba(250, 204, 21, 0.35);
  color: #facc15;
}

.cyborg-login-status-badge.badge-forbidden {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.4);
  color: #f87171;
}

body.theme-light .cyborg-login-status-badge {
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.25);
  color: #0284c7;
}

body.theme-light .cyborg-login-status-badge.badge-expired {
  background: #fef9c3;
  border-color: #facc15;
  color: #854d0e;
}

body.theme-light .cyborg-login-status-badge.badge-forbidden {
  background: #fee2e2;
  border-color: #f87171;
  color: #991b1b;
}

.cyborg-login-title {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 700;
  color: #f8fafc;
  margin: 0;
  letter-spacing: -0.02em;
}

body.theme-light .cyborg-login-title {
  color: #0f172a;
}

.cyborg-login-subtitle {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--term-dim, #94a3b8);
  margin: -6px 0 0 0;
  line-height: 1.45;
}

/* Form Styles */
.cyborg-login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-label {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
}

body.theme-light .login-label {
  color: #334155;
}

.login-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.login-input-icon {
  position: absolute;
  left: 12px;
  font-size: 0.95rem;
  color: #64748b;
  pointer-events: none;
}

.login-input {
  width: 100%;
  height: 44px;
  padding: 0 12px 0 38px;
  background: #090d16;
  border: 1px solid #1e293b;
  border-radius: 8px;
  color: #f1f5f9;
  font-family: var(--font-sans);
  font-size: 15px; /* >= 16px handled on mobile to prevent iOS zoom */
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

body.theme-light .login-input {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.login-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

body.theme-light .login-input:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.login-toggle-pw {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  font-size: 1rem;
  color: #64748b;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}

.login-toggle-pw:hover {
  color: #cbd5e1;
}

body.theme-light .login-toggle-pw:hover {
  color: #0f172a;
}

/* Error Banner */
.login-error-alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  line-height: 1.4;
  animation: errorShake 0.3s ease;
}

body.theme-light .login-error-alert {
  background: #fee2e2;
  border-color: #f87171;
  color: #991b1b;
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* Submit Button */
.cyborg-login-submit-btn {
  width: 100%;
  height: 44px;
  margin-top: 4px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 8px;
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.35);
  transition: all 0.2s ease;
}

.cyborg-login-submit-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.5);
}

.cyborg-login-submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.cyborg-login-submit-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Spinner */
.cyborg-login-submit-btn .btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.cyborg-login-footer-info {
  margin-top: 2px;
  text-align: center;
}

.cyborg-login-footer-info p {
  font-family: var(--font-sans);
  font-size: 0.76rem;
  color: #64748b;
  margin: 0;
  line-height: 1.4;
}

/* Mobile Responsiveness for Login Modal */
@media (max-width: 600px) {
  .cyborg-login-modal {
    padding: 10px;
    align-items: flex-end; /* Mobile bottom sheet style or centered */
  }

  .cyborg-login-card {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
  }

  .cyborg-login-body {
    padding: 18px 16px 24px 16px;
  }

  .login-input {
    font-size: 16px; /* Prevents auto-zoom on iOS */
    height: 46px;
  }

  .cyborg-login-submit-btn {
    height: 46px;
    font-size: 1rem;
  }
}


