/* Fixed portals keep service-table dimensions independent from hover state. */
.xb-note-popover {
  position: fixed; z-index: 180; box-sizing: border-box;
  width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 16px 18px; border: 1px solid #ffffff20; border-radius: 14px;
  color: #f0f8ff; background: var(--xb-navy, #0f172a);
  box-shadow: 0 14px 40px #0f172a30; font-size: 13px; line-height: 1.75;
  overflow: auto; overscroll-behavior: contain; overflow-wrap: anywhere;
}
.xb-note-popover[hidden], .xb-note-full-link[hidden] { display: none !important; }

/* Customer service remarks: tight tip, note text only (no heading / empty frame). */
.xb-note-popover.xb-customer-note-popover {
  width: max-content;
  max-width: min(260px, calc(100vw - 24px));
  min-width: 0;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.45;
  max-height: min(240px, calc(100dvh - 24px));
}
.xb-customer-note-popover .xb-note-popover-heading,
.xb-customer-note-popover .xb-note-full-link { display: none !important; }
.xb-customer-note-popover .xb-note-popover-body {
  max-height: min(220px, calc(100dvh - 40px));
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: auto;
}
.xb-customer-note-popover .xb-note-popover-body p { margin: 0; min-height: 0; }
.xb-note-popover-heading { display: block; margin-bottom: 7px; color: #bae6fd; font-size: 13px; }
.xb-note-popover-body p, .xb-note-full-body p { margin: 0 0 9px; white-space: pre-wrap; }
.xb-note-popover-body p:last-child, .xb-note-full-body p:last-child { margin-bottom: 0; }
.xb-note-is-long .xb-note-popover-body { max-height: min(270px, calc(100dvh - 160px)); overflow: hidden; }
.delivery-note-info > .delivery-note-text { display: none !important; }
.delivery-note-trigger {
  display: inline-flex; align-items: center; gap: 5px; min-height: 30px;
  max-width: 100%; padding: 3px 0; border: 0; background: transparent;
  color: var(--xb-muted, #526b8c); font: inherit; font-size: 12px;
  line-height: 1.5; white-space: nowrap; cursor: help;
}
.delivery-note-trigger:hover, .delivery-note-trigger[aria-expanded="true"] { color: var(--xb-primary, #2563eb); }
.delivery-note-trigger:focus-visible { outline: 2px solid #38bdf8; outline-offset: 3px; border-radius: 4px; }
.delivery-note-trigger svg { flex: 0 0 16px; width: 16px; height: 16px; }
.xb-delivery-note-popover .xb-note-popover-body {
  max-height: min(320px, calc(100dvh - 100px)); overflow: auto;
  overscroll-behavior: contain; scrollbar-gutter: stable;
}
.xb-delivery-note-popover .xb-note-popover-body p { min-height: 1em; }
.xb-note-full-link {
  display: block; margin-top: 11px; padding: 5px 0; border: 0; background: transparent;
  color: #7dd3fc; font: inherit; font-weight: 700; text-align: left; cursor: pointer;
}
.xb-note-full-link:focus-visible, .xb-note-close:focus-visible { outline: 2px solid #38bdf8; outline-offset: 3px; }
.xb-note-full-dialog {
  width: min(640px, calc(100vw - 28px)); max-height: calc(100dvh - 36px); margin: auto; padding: 24px;
  box-sizing: border-box; border: 1px solid var(--xb-line, #dce8f5); border-radius: 20px;
  background: #fff; color: var(--xb-ink, #0f172a); overflow: auto;
  box-shadow: 0 20px 60px #0f172a30; overflow-wrap: anywhere;
}
.xb-note-full-dialog::backdrop { background: #0f172a70; }
.xb-note-full-dialog h2 { margin: 0 0 16px; font-size: 20px; }
.xb-note-full-body { line-height: 1.8; font-size: 14px; }
.xb-note-close { margin-top: 20px; min-height: 42px; padding: 9px 24px; border: 0; border-radius: 10px; background: var(--xb-primary, #2563eb); color: #fff; font: inherit; cursor: pointer; }
.xb-note-edit { margin: 20px 0 0 10px; min-height: 44px; padding: 9px 20px; border: 1px solid var(--xb-primary, #2563eb); border-radius: 10px; background: #fff; color: var(--xb-primary, #2563eb); font: inherit; cursor: pointer; }
.xb-note-edit:focus-visible { outline: 2px solid #38bdf8; outline-offset: 3px; }
@media (min-width: 1024px) {
  .delivery-attention.xb-note-managed .delivery-attention-content,
  .delivery-attention.xb-note-managed:hover .delivery-attention-content,
  .delivery-attention.xb-note-managed:focus-within .delivery-attention-content,
  .proxy-info-hover.xb-note-managed > .proxy-info-tooltip,
  .proxy-info-hover.xb-note-managed:hover > .proxy-info-tooltip,
  .proxy-info-hover.xb-note-managed:focus > .proxy-info-tooltip { display: none !important; }
  .desktop-note-control.xb-note-managed:hover .customer-note,
  .desktop-note-control.xb-note-managed:focus-within .customer-note { display: block; }
  .desktop-note-control.xb-note-managed .desktop-note-input {
    position: relative; width: 100%; max-width: none; opacity: 1; pointer-events: auto; display: block;
  }
  .desktop-note-control.xb-note-managed .desktop-note-input:focus { opacity: 1; pointer-events: auto; }
  .delivery-attention.xb-note-managed .delivery-attention-label { cursor: help; }
}
@media (max-width: 1023px) {
  .xb-note-popover { display: none !important; }
  .xb-note-full-dialog { padding: 20px; }
  .delivery-note-trigger { min-height: 40px; padding: 7px 2px; cursor: pointer; }
}
@media (prefers-reduced-motion: reduce) {
  .xb-note-popover, .xb-note-full-dialog { animation: none !important; transition: none !important; }
}

/* Align delivery-note tip density with customer remarks (compact, no empty frame). */
.xb-note-popover.xb-delivery-note-popover {
  width: max-content;
  max-width: min(320px, calc(100vw - 24px));
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
}
.xb-delivery-note-popover .xb-note-popover-heading { margin-bottom: 4px; font-size: 12px; }

/* Mobile customer-note editor — textarea only; backdrop dismiss saves. */
.xb-note-edit-dialog {
  width: min(100vw - 24px, 420px);
  max-height: min(70dvh, 420px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--xb-line, #dce8f5);
  border-radius: 16px;
  background: transparent;
  overflow: visible;
  box-shadow: none;
}
.xb-note-edit-dialog::backdrop { background: #0f172a70; }
.xb-note-edit-panel {
  padding: 14px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 48px #0f172a33;
}
.xb-note-edit-input {
  display: block;
  width: 100%;
  min-height: 140px;
  max-height: min(52dvh, 320px);
  margin: 0;
  padding: 12px;
  box-sizing: border-box;
  border: 1px solid #cfe0f5;
  border-radius: 12px;
  background: #f8fbff;
  color: var(--xb-ink, #0f172a);
  font: inherit;
  font-size: 16px; /* reduce iOS focus zoom */
  line-height: 1.55;
  resize: vertical;
  outline: none;
}
.xb-note-edit-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px #38bdf833;
}
.service-note-label, .service-customer-note .service-note-label { display: none !important; }
.xb-note-full-dialog .xb-note-close,
.xb-note-full-dialog .xb-note-edit { display: none !important; }
