/* P11 owns only the existing customer history dialog. */
html:has(#customer-history[open]) { overflow: hidden; }
#customer-history { width: min(1180px, calc(100vw - 48px)); height: min(940px, calc(100dvh - 48px)); max-width: none; max-height: none; margin: auto; padding: 0; border: 1px solid #d2dfdc; border-radius: 18px; background: #fff; color: #192c2b; font: 16px/1.5 Manrope, "Segoe UI", sans-serif; box-shadow: 0 24px 100px #142c2b35; overflow: hidden; }
#customer-history[open] { display: flex; flex-direction: column; }
#customer-history::backdrop { background: #172c3180; backdrop-filter: blur(3px); }
#customer-history [hidden] { display: none !important; }
#customer-history button, #customer-history input, #customer-history select { min-height: 44px; border: 1px solid #c9d8d4; border-radius: 10px; padding: 10px 14px; color: #192c2b; background: #fff; font: inherit; }
#customer-history button { cursor: pointer; font-size: 14px; font-weight: 700; }
#customer-history button:hover:not(:disabled) { background: #e9f9f1; }
#customer-history button:disabled { opacity: .45; cursor: not-allowed; }
#customer-history .mc-primary { background: #48dfad; border-color: #48dfad; }
#customer-history :focus-visible { outline: 3px solid #287a61; outline-offset: 3px; }
#customer-history p { margin: 0; overflow-wrap: anywhere; }
#customer-history .customer-history-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; padding: 20px 26px; border-bottom: 1px solid #dce5e5; background: #fff; flex: none; }
#customer-history .customer-history-head > div { min-width: 0; }
#customer-history #customer-history-title { color: #596c74; font-size: 14px; margin-bottom: 6px; }
#customer-history h2 { font: 750 21px/1.35 Manrope, "Segoe UI", sans-serif; letter-spacing: -.4px; margin: 0 0 6px; overflow-wrap: anywhere; text-transform: none; }
#customer-history-meta { color: #596c74; font-size: 14px; }
#customer-history #customer-history-close { width: 44px; height: 44px; font-size: 26px; line-height: 1; padding: 0; flex: none; }
#customer-history .customer-history-body { flex: 1; overflow: auto; min-height: 0; padding: 20px 26px; overscroll-behavior: contain; scrollbar-gutter: stable; }
#customer-history .customer-history-balances { display: flex; gap: 32px; flex-wrap: wrap; margin-bottom: 18px; }
#customer-history .customer-history-balances span { display: block; font-size: 14px; color: #596c74; }
#customer-history .customer-history-balances strong { display: block; font-size: 21px; font-variant-numeric: tabular-nums; }
#customer-history .customer-history-overview { border: 1px solid #dce5e5; border-radius: 10px; background: #f8fbfa; padding: 0 14px; }
#customer-history summary { min-height: 44px; cursor: pointer; align-content: center; padding: 10px 0; font-size: 14px; font-weight: 650; color: #213d34; }
#customer-history .customer-history-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 14px 0; }
#customer-history .customer-history-summary span { display: block; font-size: 14px; color: #596c74; }
#customer-history .customer-history-summary strong { display: block; font-size: 19px; }
#customer-history .customer-history-explainer, #customer-history #customer-history-purchases, #customer-history #customer-history-last-order { font-size: 14px; color: #596c74; margin-bottom: 12px; }
#customer-history .customer-history-tabs { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; padding: 5px; margin: 18px 0 14px; border: 1px solid #dce5e5; border-radius: 12px; background: #f5f8f7; }
#customer-history .customer-history-tabs button { display: flex; gap: 8px; justify-content: center; align-items: center; border-color: transparent; background: transparent; padding: 8px; }
#customer-history .customer-history-tabs button[aria-selected="true"] { border-color: #bdd8cb; background: #fff; color: #205e49; box-shadow: 0 1px 3px #193f3210; }
#customer-history .customer-history-tabs span { font-size: 14px; color: #596c74; font-weight: 500; }
#customer-history .customer-history-section-note { font-size: 14px; color: #596c74; margin: 12px 0; }
#customer-history .customer-history-filter { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 10px; align-items: end; }
#customer-history label { display: grid; gap: 6px; font-size: 14px; font-weight: 650; min-width: 0; }
#customer-history input, #customer-history select { width: 100%; min-width: 0; font-size: 16px; font-weight: 400; }
#customer-history .customer-history-advanced { grid-column: 1/-1; margin-top: 2px; }
#customer-history .customer-history-filter-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; align-items: end; gap: 12px; padding: 8px 0 12px; }
#customer-history .customer-history-advanced p { font-size: 14px; color: #596c74; margin: 8px 0; }
#customer-history .customer-history-tools { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; }
#customer-history-status { font-size: 14px; color: #596c74; }
#customer-history .customer-history-selection { border-top: 1px solid #dce5e5; border-bottom: 1px solid #dce5e5; margin-bottom: 12px; }
#customer-history .customer-history-selection:empty { display: none; }
#customer-history .customer-history-selection details > div { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; padding: 14px 0; }
#customer-history .customer-history-selection span { color: #596c74; font-size: 14px; }
#customer-history .customer-history-selection strong { display: block; color: #192c2b; font-size: 18px; overflow-wrap: anywhere; }
#customer-history-items { display: grid; gap: 10px; }
#customer-history .customer-history-entry { padding: 0; min-width: 0; border: 1px solid #dce5e5; border-radius: 12px; background: #fff; overflow: hidden; }
#customer-history .customer-history-entry summary { display: grid; grid-template-columns: minmax(0,1fr) minmax(130px,180px) minmax(135px,max-content); gap: 18px; align-items: center; padding: 16px; list-style: none; font-weight: 400; }
#customer-history .customer-history-entry summary::-webkit-details-marker { display: none; }
#customer-history .customer-history-entry summary:hover { background: #f7fbf9; }
#customer-history .history-record-main { min-width: 0; }
#customer-history time { display: block; color: #596c74; font-size: 14px; margin-bottom: 4px; }
#customer-history .history-record-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 16px; font-weight: 650; overflow-wrap: anywhere; }
#customer-history .history-record-amount { text-align: right; min-width: 0; }
#customer-history .history-record-amount strong { display: block; font-variant-numeric: tabular-nums; font-size: 16px; white-space: nowrap; }
#customer-history .history-record-open, #customer-history .history-record-close { display: block; color: #276d58; font-size: 14px; padding-top: 4px; }
#customer-history .history-record-close { display: none; }
#customer-history details[open] > summary .history-record-close { display: block; }
#customer-history details[open] > summary .history-record-open { display: none; }
#customer-history .history-state { width: fit-content; max-width: 100%; border-radius: 6px; padding: 4px 8px; font-size: 14px; background: #eef2f4; color: #4d6570; overflow-wrap: anywhere; }
#customer-history .history-state-completed, #customer-history .history-state-credit { background: #e6f7ee; color: #25664d; }
#customer-history .history-state-pending, #customer-history .history-state-partial { background: #fff6dd; color: #765d14; }
#customer-history .history-state-cancelled, #customer-history .history-state-debit { background: #fff0ee; color: #8f4646; }
#customer-history .customer-history-details { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; margin: 0; padding: 18px 16px; border-top: 1px solid #dce5e5; background: #fafcfb; }
#customer-history .customer-history-details > div { min-width: 0; }
#customer-history .customer-history-details .history-wide { grid-column: 1/-1; }
#customer-history dt { font-size: 14px; color: #596c74; }
#customer-history dd { margin: 4px 0 0; font-size: 15px; overflow-wrap: anywhere; white-space: pre-wrap; }
#customer-history dd a { color: #276d58; text-decoration: underline; }
#customer-history .customer-history-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 26px; background: #fafcfb; border-top: 1px solid #dce5e5; flex: none; font-size: 14px; }
#customer-history .customer-history-footer > div { display: flex; gap: 8px; }
#customer-history-error { padding: 16px; border: 1px solid #e7b0a5; background: #fff3f0; border-radius: 12px; }
#customer-history-error p { margin-bottom: 12px; }
@media (max-width: 760px) {
  #customer-history { width: calc(100vw - 20px); height: calc(100dvh - 20px); border-radius: 15px; }
  #customer-history .customer-history-head, #customer-history .customer-history-body, #customer-history .customer-history-footer { padding: 16px; }
  #customer-history h2 { font-size: 18px; }
  #customer-history .customer-history-entry summary { grid-template-columns: minmax(0,1fr) auto; gap: 12px; }
  #customer-history .history-record-main { grid-column: 1/-1; }
  #customer-history .customer-history-filter { grid-template-columns: 1fr 1fr; }
  #customer-history .customer-history-filter > label { grid-column: 1/-1; }
  #customer-history .customer-history-filter-grid, #customer-history .customer-history-details { grid-template-columns: 1fr 1fr; }
  #customer-history .customer-history-filter-grid > label:first-child { grid-column: 1/-1; }
  #customer-history .customer-history-tabs button { flex-direction: column; gap: 2px; }
}
@media (max-width: 480px) {
  #customer-history .customer-history-tabs { grid-template-columns: 1fr 1fr; }
  #customer-history .customer-history-tabs button { flex-direction: row; gap: 8px; }
  #customer-history .customer-history-entry summary, #customer-history .customer-history-details, #customer-history .customer-history-filter-grid, #customer-history .customer-history-summary, #customer-history .customer-history-selection details > div { grid-template-columns: minmax(0,1fr); }
  #customer-history .history-record-amount { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; }
  #customer-history .customer-history-balances { display: grid; grid-template-columns: 1fr; gap: 10px; }
  #customer-history .customer-history-balances strong { font-size: 19px; }
  #customer-history .customer-history-footer { flex-wrap: wrap; justify-content: center; padding: 10px 14px; }
  #customer-history .customer-history-footer > div { width: 100%; justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) { #customer-history *, #customer-history *::before, #customer-history *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
