/* ==========================================================================
   Taha Auto admin: Analytics Plus (js/analytics-plus.js). The detailed Shop cards, the Reports view
   (builder, chart, table), the four-view switch and the five Shop periods. Only the tokens css/analytics.css
   already uses (no new colours); navy gets the same card surfaces at the end. The Export layer
   (js/report-export.js) and the print block (#anx-print, black on white, no navy tokens on paper) are at the end.
   ========================================================================== */

/* ---------- the header: four views (Shop · Reports · Website · Specials), five Shop periods ---------- */
.anx__view--4 { grid-template-columns: repeat(4, auto); }
.anx__seg:has(> :nth-child(5)) { grid-template-columns: repeat(5, minmax(0, 1fr)); max-width: 680px; }
@media (max-width: 559px) {
  .anx .anx__head:has(.anx__view--4) { grid-template-columns: minmax(0, 1fr) 44px; grid-template-areas: "grab grab" "title x" "view view" "seg seg"; }
  .anx__view--4 { justify-self: stretch; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 8px; }
  .anx__view--4 button { min-width: 0; padding: 0 4px; }
  /* five periods on a phone: one row that scrolls inside itself, chips as wide as their words */
  .anx__seg:has(> :nth-child(5)) { display: flex; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .anx__seg:has(> :nth-child(5))::-webkit-scrollbar { display: none; }
  .anx__seg:has(> :nth-child(5)) button { flex: 1 0 auto; padding: 0 12px; }
}
@media (max-width: 359px) {
  .anx__view--4 { display: flex; overflow-x: auto; scrollbar-width: none; }
  .anx__view--4::-webkit-scrollbar { display: none; }
  .anx__view--4 button { flex: 1 0 auto; padding: 0 10px; }
  .anx__seg:has(> :nth-child(5)) button { white-space: nowrap; line-height: 1; }
}

/* ---------- Shop: the action row under the hero ---------- */
.anxp-act { display: grid; gap: 10px; min-width: 0; }
.anxp-act__row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 12px; }
.anxp-act__btns { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.anxp-act__btns .btn { min-height: 44px; }
.anxp-how { min-width: 0; }
.anxp-how summary { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; color: var(--accent-text); font-size: 14px; font-weight: 650; list-style: none; cursor: pointer; }
.anxp-how summary::-webkit-details-marker { display: none; }
.anxp-how summary::before { content: ""; width: 7px; height: 7px; margin: 0 2px 3px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform var(--dur-small) var(--ease-out); }
.anxp-how[open] summary::before { margin-bottom: 5px; transform: rotate(45deg); }
.anxp-how summary:focus-visible { outline: 2px solid var(--accent-ui); outline-offset: 2px; border-radius: 6px; }
.anxp-how[open] { flex: 1 0 100%; order: 2; }
.anxp-how__body { display: grid; gap: 6px; padding: 4px 0 2px; }
.anxp-how p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--text-2); }
.anxp-how b { color: var(--text); font-weight: 700; }
.anxp-how--rep { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.anxp-how--rep h4 { margin: 0 0 2px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.anxp-sample { margin: 0; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--accent-soft); font-size: 13.5px; line-height: 1.45; color: var(--text-2); }
.anxp-sample b { margin-right: 6px; padding: 2px 8px; border-radius: 999px; background: var(--card); color: var(--accent-text); font-size: 11px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.anxp-sample--sm { margin-bottom: 12px; padding: 8px 12px; font-size: 13px; }
.anxp-cover { break-inside: avoid; padding: 0 4px; }

/* the small tables: compared with, sales tax, the report's rows */
.anxp-tw { min-width: 0; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.anxp-tw:focus-visible { outline: 2px solid var(--accent-ui); outline-offset: 2px; border-radius: 6px; }
.anxp-t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.anxp-t th, .anxp-t td { padding: 9px 0 9px 12px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; }
.anxp-t th:first-child { padding-left: 0; text-align: left; }
.anxp-t thead th { border-top: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.anxp-t tbody th { font-weight: 500; color: var(--text-2); }
.anxp-t tfoot th, .anxp-t tfoot td { font-weight: 750; color: var(--text); border-top-color: var(--line-2); }
.anxp-t--cmp tbody th { white-space: normal; }
.anxp-chg { font-weight: 700; color: var(--text-3); white-space: nowrap; }
.anxp-chg--up { color: var(--ok-text, var(--text-2)); }
.anxp-chg--down { color: var(--warn-text, var(--text-2)); }
.anxp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.anxp-more { margin-top: 2px; }
.anxp-card .anx-bar__l { white-space: normal; }
.anxp-card .anx-bar__l small { display: block; margin: 2px 0 0; }

/* ---------- Reports: Ready-made / Saved and the builder beside the result ---------- */
.anxp-rep { display: grid; gap: 12px; min-width: 0; }
.anxp-side, .anxp-main { display: grid; gap: 12px; align-content: start; min-width: 0; }
@media (min-width: 900px) {
  .anxp-rep { grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
  .anxp-side { position: sticky; top: 104px; max-height: calc(min(92dvh, 940px) - 128px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
}
.anxp-chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.anxp-chips .chip { min-height: 40px; padding: 8px 12px; }
.anxp-chips--scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.anxp-chips--scroll::-webkit-scrollbar { display: none; }
.anxp-chips--scroll .chip { flex: none; white-space: nowrap; }
@media (min-width: 900px) { .anxp-chips--scroll { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; } }
.anxp-lib__h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 16px 0 8px; }
.anxp-lib__h h3 { margin: 0; font-size: 16px; font-weight: 700; }
.anxp-saved { display: grid; margin: 0; padding: 0; list-style: none; }
.anxp-sv { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; gap: 4px 8px; padding: 2px 0; border-top: 1px solid var(--line); }
.anxp-sv:first-child { border-top: 0; }
.anxp-sv__run { min-width: 0; min-height: 52px; display: grid; gap: 2px; padding: 6px 0; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.anxp-sv__run b { overflow: hidden; font-size: 14px; font-weight: 650; white-space: nowrap; text-overflow: ellipsis; }
.anxp-sv__run small { overflow: hidden; font-size: 12.5px; color: var(--text-3); white-space: nowrap; text-overflow: ellipsis; }
.anxp-sv__run:focus-visible { outline: 2px solid var(--accent-ui); outline-offset: 2px; border-radius: 8px; }
.anxp-sv__more { width: 44px; height: 44px; font-size: 18px; line-height: 1; }
.anxp-sv__menu, .anxp-sv__btns { grid-column: 1 / -1; display: flex; gap: 8px; padding-bottom: 8px; }
.anxp-sv.is-edit { grid-template-columns: minmax(0, 1fr); padding: 8px 0; }
.anxp-sv .btn { min-height: 44px; }

.anxp-f { display: grid; gap: 6px; min-width: 0; margin-top: 12px; }
.anxp-f:first-of-type { margin-top: 0; }
.anxp-f > label, .anxp-l { font-size: 12.5px; font-weight: 700; letter-spacing: .02em; color: var(--text-2); }
.anxp-f .og-input { width: 100%; min-width: 0; min-height: 44px; font-size: 16px; }   /* 16px: the iPhone doesn't zoom into it */
.anxp-ms { display: grid; gap: 6px; }
.anxp-mrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.anxp-mrow > select:only-child { grid-column: 1 / -1; }
.anxp-mrow__x, .anxp-add__x { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; }
.anxp-mrow__x svg, .anxp-add__x svg { width: 16px; height: 16px; }
.anxp-link { justify-self: start; min-height: 44px; font-size: 14px; font-weight: 650; text-decoration: none; }
.anxp-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.anxp-dates label { display: grid; gap: 4px; min-width: 0; font-size: 12.5px; color: var(--text-3); }
.anxp-add { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 6px; }
.anxp-add > select:first-of-type { grid-column: 1; }
.anxp-add > [data-anxp-fv], .anxp-add > [data-anxp-fv-cust] { grid-column: 1; grid-row: 2; }
.anxp-add__x { grid-column: 2; grid-row: 1; }
.anxp-addf { justify-self: start; min-height: 44px; }
.anxp-fchip { display: inline-flex; align-items: center; gap: 6px; }
.anxp-fchip span { font-size: 16px; line-height: 1; }

/* the result */
.anxp-hl { display: grid; gap: 4px; margin-bottom: 4px; }
.anxp-hl__m { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin: 0; font-size: 14px; color: var(--text-2); }
.anxp-hl__k { font-weight: 650; }
.anxp-hl__v { font-size: 22px; font-weight: 800; letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.anxp-hl__m:first-child .anxp-hl__v { font-size: clamp(28px, 8vw, 34px); }
.anxp-hl__c { font-size: 13px; color: var(--text-3); }
.anxp-chart { cursor: default; }
.anxp-chart .anx-chart__plot { height: 150px; }
@media (min-width: 900px) { .anxp-chart .anx-chart__plot { height: 220px; } }
.anxp-chart .anx-col { gap: 1px; }
.anxp-chart .anx-col i.anxp-prev { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--line-2); }
.anxp-res .anx-bars { margin-top: 12px; }
.anxp-res .anxp-tw { margin-top: 14px; }
.anxp-sort { min-height: 32px; padding: 0; border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; white-space: nowrap; }
.anxp-sort:focus-visible, .anxp-go:focus-visible { outline: 2px solid var(--accent-ui); outline-offset: 2px; border-radius: 4px; }
.anxp-go { min-height: 32px; padding: 0; border: 0; background: none; color: var(--accent-text); font: inherit; font-weight: 600; text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
/* the first column stays put while the numbers scroll under it (phone) */
.anxp-t--rep th:first-child { position: sticky; left: 0; z-index: 1; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; background: var(--card); }
.anxp-t--rep thead th:first-child { z-index: 2; }
.anxp-t__rest th { color: var(--text-3); font-style: italic; }
.anxp-nomatch { margin-top: 12px; }
.anxp-notes { display: grid; gap: 4px; margin: 12px 0 0; padding: 0 0 0 18px; font-size: 13px; line-height: 1.45; color: var(--text-3); }
.anxp-err { color: var(--warn-text, var(--text-2)); }
.anxp-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.anxp-acts .btn { min-height: 44px; }
.anxp-save { flex: 1 1 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: end; gap: 8px; }
.anxp-save label { grid-column: 1 / -1; font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.anxp-save .og-input { min-width: 0; min-height: 44px; font-size: 16px; }
@media (max-width: 400px) { .anxp-save { grid-template-columns: 1fr 1fr; } .anxp-save .og-input { grid-column: 1 / -1; } }

@media (prefers-reduced-motion: reduce) { .anxp-how summary::before { transition: none; } }
@media (forced-colors: active) {
  .anxp-chart .anx-col i.anxp-prev { background: Canvas; box-shadow: inset 0 0 0 1px CanvasText; forced-color-adjust: none; }
  .anxp-chg--up, .anxp-chg--down { forced-color-adjust: auto; }
}

/* ---------- navy: the same card surfaces as the rest of the sheet ---------- */
body.theme-navy .anxp-t--rep th:first-child { background: #12202D; }
body.theme-navy .anxp-sample { background: color-mix(in srgb, var(--accent) 10%, #0F1B27); border-color: #203346; }
body.theme-navy .anxp-sample b { background: #0C1721; }

/* ---------- the Export layer: a view state inside the Analytics box (js/report-export.js), not a second sheet ---------- */
.anx__box.anx--export > .anx__head, .anx__box.anx--export > .anx__body { display: none; }
.anxx { display: grid; gap: 12px; min-width: 0; padding-bottom: 8px; }
.anxx__head { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: auto minmax(0, 1fr) 44px; grid-template-areas: "back title x"; align-items: center; gap: 12px; margin: 0 -24px; padding: 18px 24px 14px; background: inherit; border-bottom: 1px solid var(--line); }
.anxx__head h2 { grid-area: title; min-width: 0; margin: 0; }
.anxx__head h2:focus { outline: none; }
.anxx__back { grid-area: back; min-height: 44px; padding: 0 12px; }
.anx .anxx__x { grid-area: x; display: grid; }
.anxx__lead { margin: 0; font-size: 14px; line-height: 1.45; color: var(--text-2); }
.anxx__what { margin: 0 0 10px; font-size: 13.5px; color: var(--text-2); overflow-wrap: anywhere; }
.anxx__btns { display: flex; flex-wrap: wrap; gap: 8px; }
.anxx__btns .btn { min-height: 44px; }
.anxx__dates { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin-bottom: 10px; }
.anxx__dates > label, .anxx__pick label { display: grid; gap: 4px; font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.anxx__dates > label { width: 100%; }
.anxx__dates select, .anxx__pick input { min-height: 44px; font-size: 16px; min-width: 0; }
.anxx__dates select { flex: 1 1 220px; max-width: 320px; }
.anxx__pick { display: flex; flex-wrap: wrap; gap: 8px; }
.anxx__raw { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.anxx__raw li { display: grid; grid-template-columns: 128px minmax(0, 1fr); align-items: center; gap: 4px 12px; }
.anxx__raw .btn { min-height: 44px; justify-content: center; }
.anxx__raw small { font-size: 13px; line-height: 1.4; color: var(--text-3); }
.anxx__fb p { margin: 0 0 10px; font-size: 14px; line-height: 1.45; color: var(--text-2); }
.anxx__text { width: 100%; margin-top: 10px; min-height: 160px; font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; overflow: auto; }
.anxx__foot { margin: 0; }
@media (min-width: 900px) { .anxx__sec, .anxx__fb { max-width: 720px; } }
@media (max-width: 720px) {
  .anxx__head { top: -16px; grid-template-columns: auto minmax(0, 1fr) 44px; grid-template-areas: "grab grab grab" "back title x"; column-gap: 8px; row-gap: 0; margin: -16px -16px 0; padding: 6px 12px 12px 8px; border-radius: inherit; touch-action: none; }
  .anxx__head .sheet__grab { grid-area: grab; }
  .anxx__raw li { grid-template-columns: minmax(0, 1fr); }
  .anxx__raw .btn { width: 100%; }
  .anxx__pick label { flex: 1 1 140px; }
}
body.theme-navy .anxx__head { border-bottom-color: #203140; }

/* ---------- the printable page (§3.4): only #anx-print goes to paper, black on white ---------- */
#anx-print { display: none; }
@media print {
  @page { size: letter; margin: 0.5in; }
  body.anx-printing { background: #fff !important; color: #000 !important; padding: 0 !important; margin: 0 !important; }
  body.anx-printing > :not(#anx-print) { display: none !important; }
  body.anx-printing #anx-print { display: block !important; color: #000; background: #fff; font: 11pt/1.45 -apple-system, "Helvetica Neue", Arial, sans-serif; }
  #anx-print h1 { margin: 2px 0 4px; font-size: 18pt; color: #000; }
  #anx-print h2 { margin: 14pt 0 4pt; font-size: 10pt; text-transform: uppercase; letter-spacing: .05em; color: #000; }
  #anx-print .ap-shop { margin: 0; font-weight: 700; }
  #anx-print .ap-meta { margin: 0; color: #222; }
  #anx-print .ap-hl { display: flex; flex-wrap: wrap; gap: 6pt 20pt; margin: 10pt 0; }
  #anx-print .ap-hl dt { font-size: 9pt; color: #222; }
  #anx-print .ap-hl dd { margin: 0; font-size: 13pt; font-weight: 700; }
  #anx-print .ap-hl small { display: block; font-size: 9pt; font-weight: 400; }
  #anx-print table { width: 100%; border-collapse: collapse; margin: 8pt 0; font-variant-numeric: tabular-nums; }
  #anx-print caption { text-align: left; font-weight: 700; padding: 3pt 0; }
  #anx-print th, #anx-print td { padding: 3pt 5pt; border-bottom: 1px solid #999; text-align: right; white-space: nowrap; color: #000; background: none; }
  #anx-print th:first-child { text-align: left; white-space: normal; }
  #anx-print thead th { border-bottom: 2px solid #000; font-size: 9pt; }
  #anx-print tfoot th, #anx-print tfoot td { font-weight: 700; border-top: 2px solid #000; }
  #anx-print tr { break-inside: avoid; }
  #anx-print .ap-how p, #anx-print .ap-notes li { margin: 2pt 0; }
}
