/* CRM pages. The frame (menu, top bar) is shared: packages/ui/app.css. Group theme, Appendix F.6. */

.profile { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s4); }
.profile .card { display: flex; flex-direction: column; gap: var(--s4); }
.brand-cards { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.brand-card { border: 1px solid var(--line); border-radius: var(--r-btn); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.brand-card .num { font-size: var(--fs-body); font-weight: 500; }
.brand-card .brand-chip { align-self: flex-start; }

.timeline { display: flex; flex-direction: column; }
.timeline .item { display: grid; grid-template-columns: 150px 1fr auto; gap: var(--s4); padding: var(--s4) 0; border-bottom: 1px solid var(--line); align-items: start; }
.timeline .item:last-child { border-bottom: 0; }
.timeline .when { font-size: var(--fs-small); color: var(--text-soft); }
.timeline .what { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.timeline .amount { font-weight: 500; font-variant-numeric: tabular-nums; }

.consent-rows { display: flex; flex-direction: column; gap: var(--s3); }
.consent-row { display: flex; justify-content: space-between; gap: var(--s3); align-items: baseline; }

.scope-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 var(--s4); }

@media (max-width: 900px) {
  .profile { grid-template-columns: 1fr; }
  .timeline .item { grid-template-columns: 1fr; gap: var(--s2); }
}
.brand-logo { height: 32px; width: auto; max-width: 120px; object-fit: contain; }

/* ---------- shared bits ---------- */
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .92em; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { align-items: flex-end; text-align: right; }
.wrap { flex-wrap: wrap; }
.num-col { text-align: right; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.lead { font-size: var(--fs-body); color: var(--text-soft); max-width: 70ch; }
.banner.info { border-color: var(--info); }
.big-num { font-size: 34px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1; }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; flex: none; font-weight: 500;
  background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--line); letter-spacing: .02em; }
.tier-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px 0 8px; border-radius: var(--r-chip);
  font-size: var(--fs-label); font-weight: 500; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.tier-chip::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--tier); }
.chip.refund { margin-left: var(--s2); border: 1px solid var(--danger); background: transparent; font-size: var(--fs-label); }
.pill-stat { padding: var(--s1) var(--s3) var(--s1) var(--s1); border: 1px solid var(--line); border-radius: var(--r-chip); }
.customers-table td { vertical-align: middle; }
.row.bday select { width: auto; flex: 1; }
.row.bday input { width: 150px; }

/* ---------- profile ---------- */
.profile-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s6); align-items: center;
  padding: var(--s6); border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--line); }
.hero-main { gap: var(--s4); }
.pstats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); }
.pstat { display: flex; flex-direction: column; gap: 2px; padding: var(--s3) var(--s4); border-radius: var(--r-btn); background: var(--surface-2); min-width: 0; }
.pstat-label { font-size: var(--fs-label); color: var(--text-soft); }
.pstat-value { font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pstat-note { font-size: var(--fs-label); color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tier-progress { display: flex; flex-direction: column; gap: var(--s2); }
.meter { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; }

/* the member card: dark roast, the tier as a thin line of colour */
.mcard { position: relative; width: 380px; aspect-ratio: 85.6 / 54; border-radius: 22px; padding: 22px 24px; color: var(--crema);
  background: radial-gradient(120% 140% at 0% 0%, #3A2318 0%, #24120C 55%, #140A07 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 18px 40px -18px rgba(36,18,12,.55), 0 4px 12px -6px rgba(36,18,12,.35);
  display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.mcard::before { content: ''; position: absolute; inset: 0 0 auto; height: 5px; background: var(--tier); }
.mcard::after { content: ''; position: absolute; right: -40%; top: -60%; width: 90%; height: 160%; transform: rotate(18deg);
  background: linear-gradient(90deg, transparent, rgba(239,226,205,.05), transparent); pointer-events: none; }
.mcard-top { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); }
.mcard-brand { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: rgba(239,226,205,.66); }
.mcard-tier { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; padding: 5px 10px; border-radius: 999px; background: var(--tier); color: #fff; }
.mcard-body { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s3); }
.mcard-who { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mcard-label { font-size: 11px; letter-spacing: .14em; color: rgba(239,226,205,.55); }
.mcard-name { font-size: 22px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcard-no { font-size: 18px; letter-spacing: .08em; font-variant-numeric: tabular-nums; color: rgba(239,226,205,.92); }
.mcard-qr { background: #fff; border-radius: 12px; padding: 4px; line-height: 0; flex: none; }
.mcard-qr svg { width: 92px; height: 92px; }

/* ---------- overview ---------- */
.filters { flex-wrap: wrap; justify-content: flex-end; }
.filters .seg { flex: none; }
.filters select { width: auto; min-width: 160px; }
.hero-row { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: var(--s4); align-items: stretch; }
.hero-figure { display: flex; flex-direction: column; justify-content: center; gap: var(--s2); padding: var(--s5); border-radius: var(--r-card);
  background: var(--surface); border: 1px solid var(--line); }
.hero-value { font-size: clamp(34px, 3.4vw, var(--fs-number)); white-space: nowrap; font-weight: 500; line-height: 1.05; font-variant-numeric: proportional-nums; letter-spacing: -.01em; }
.hero-row .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.delta { font-size: var(--fs-label); font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }
.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); align-items: start; }
.chart-box { position: relative; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .baseline { stroke: var(--text-soft); stroke-opacity: .35; stroke-width: 1; }
.chart .axis { fill: var(--text-soft); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--primary); }
.chart .cross { stroke: var(--text-soft); stroke-opacity: .5; stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; outline: none; }
.chart-tip { position: absolute; top: 0; pointer-events: none; display: flex; flex-direction: column; gap: 2px; padding: var(--s2) var(--s3);
  border-radius: 10px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 24px -8px rgba(30,26,23,.25); white-space: nowrap; z-index: 2; }
.tip-title { font-size: var(--fs-label); color: var(--text-soft); }
.tip-value { font-weight: 500; font-variant-numeric: tabular-nums; }
.tip-note { font-size: var(--fs-label); color: var(--text-soft); }
.hbars { display: flex; flex-direction: column; gap: var(--s3); }
.hbar { display: grid; grid-template-columns: minmax(0, 170px) minmax(0, 1fr) auto; gap: var(--s3); align-items: center; }
.hbar-label { min-width: 0; overflow: hidden; }
.hbar-track { height: 14px; display: flex; align-items: center; }
.hbar-fill { display: block; height: 14px; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--primary); }
.hbar-value { display: flex; flex-direction: column; align-items: flex-end; gap: 0; min-width: 84px; }
.tier-bars { display: flex; flex-direction: column; gap: var(--s3); }
.tier-bar-row { display: grid; grid-template-columns: 120px minmax(0, 1fr) 56px; gap: var(--s3); align-items: center; }
.tier-bar-row .num { text-align: right; }
.bar-track { height: 12px; display: flex; align-items: center; }
.bar-fill { display: block; height: 12px; min-width: 2px; border-radius: 0 4px 4px 0; }
.top-list { display: flex; flex-direction: column; }
.top-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto; gap: var(--s3); align-items: center; padding: var(--s3) 0;
  border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.top-row:first-child { border-top: 0; }
.top-row:hover .strong { text-decoration: underline; }
.rank { color: var(--text-soft); font-size: var(--fs-small); }
.table.compact td, .table.compact th { padding-top: var(--s2); padding-bottom: var(--s2); }

/* ---------- receipts ---------- */
.slip { display: flex; flex-direction: column; gap: var(--s4); font-variant-numeric: tabular-nums; }
.slip-head { display: flex; gap: var(--s3); align-items: center; }
.slip-customer { display: flex; justify-content: space-between; align-items: center; padding: var(--s3) var(--s4); border-radius: var(--r-btn);
  background: var(--surface-2); color: inherit; text-decoration: none; font-weight: 500; }
.slip-lines { display: flex; flex-direction: column; gap: var(--s3); padding-top: var(--s3); border-top: 1px dashed var(--line); }
.slip-line { display: flex; justify-content: space-between; gap: var(--s3); }
.slip-mod { display: flex; justify-content: space-between; gap: var(--s3); padding-left: var(--s4); font-size: var(--fs-small); color: var(--text-soft); }
.slip-totals { display: flex; flex-direction: column; gap: var(--s1); padding-top: var(--s3); border-top: 1px dashed var(--line); font-size: var(--fs-small); }
.slip-line.total { font-size: var(--fs-body); font-weight: 500; padding-top: var(--s2); }
.slip-points { display: flex; flex-wrap: wrap; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-btn); border: 1px solid var(--line); font-size: var(--fs-small); }

/* ---------- loyalty ---------- */
.loyalty-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); align-items: start; }
.rate-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px auto; gap: var(--s3); align-items: center; }
.tier-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 140px 110px auto; gap: var(--s3); align-items: end;
  padding: var(--s3); border-radius: var(--r-btn); border: 1px solid var(--line); box-shadow: inset 4px 0 0 var(--tier); }
.tier-swatch input { width: 44px; height: 44px; padding: 0; border: 0; background: none; }
.loyalty-preview { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3); border-radius: var(--r-btn); background: var(--surface-2); }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s2); }
.preview-cell { display: flex; flex-direction: column; gap: 4px; padding: var(--s3); border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.preview-pts { font-size: 20px; font-weight: 500; }

/* ---------- API keys and the guide ---------- */
.scope-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s2); }
.scope-item { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3); border-radius: var(--r-btn); border: 1px solid var(--line); cursor: pointer; }
.scope-item input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.base-url { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.base-url code { padding: var(--s2) var(--s3); border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.guide { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--s5); align-items: start; }
.guide-toc { position: sticky; top: var(--s5); display: flex; flex-direction: column; gap: 2px; }
.guide-toc a { padding: var(--s2) var(--s3); border-radius: 10px; color: var(--text-soft); text-decoration: none; font-size: var(--fs-small); }
.guide-toc a:hover { background: var(--surface); color: var(--text); }
.guide-h { font-size: 22px; font-weight: 500; margin: 0; }
.guide-section p { margin: 0; max-width: 80ch; }
.endpoint { border: 1px solid var(--line); border-radius: var(--r-btn); background: var(--surface); }
.endpoint > summary { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); cursor: pointer; list-style: none; flex-wrap: wrap; }
.endpoint > summary::-webkit-details-marker { display: none; }
.endpoint[open] > summary { border-bottom: 1px solid var(--line); }
.endpoint > div { padding: var(--s4); }
.method { font: 700 12px/1 ui-monospace, Menlo, monospace; padding: 5px 8px; border-radius: 6px; letter-spacing: .04em; color: #fff; }
.m-get { background: #3F7D6A; } .m-post { background: #24120C; } .m-patch { background: #A5563A; } .m-put { background: #7B3B26; } .m-delete { background: #B4412E; }
.path { font-size: var(--fs-small); overflow-wrap: anywhere; }
.ep-title { font-size: var(--fs-small); color: var(--text-soft); }
.chip.scope { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.code-box { position: relative; }
.code-box .copy { position: absolute; top: 6px; right: 6px; background: var(--surface); }
.code { margin: 0; padding: var(--s4); padding-right: 72px; border-radius: 12px; background: #1E1A17; color: #EFE2CD; overflow: auto; max-height: 460px;
  font: 13px/1.55 ui-monospace, 'SF Mono', Menlo, monospace; white-space: pre; }
.j-key { color: #D9BE98; } .j-str { color: #A8C99B; } .j-num { color: #E6A86A; } .j-lit { color: #9DB7D4; }
.fields td:first-child { width: 220px; }
.recipe ol { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: var(--s2); }

@media (max-width: 1100px) {
  .profile-hero { grid-template-columns: 1fr; }
  .mcard { width: min(380px, 100%); }
  .hero-row { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .pstats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid, .loyalty-grid { grid-template-columns: 1fr; }
  .guide { grid-template-columns: 1fr; }
  .guide-toc { position: static; flex-direction: row; overflow-x: auto; }
  .tier-row { grid-template-columns: 44px 1fr 1fr; }
  .tier-row > :nth-child(4), .tier-row > :nth-child(5) { grid-column: auto; }
  .hbar { grid-template-columns: minmax(0, 110px) minmax(0, 1fr) auto; }
  .profile-hero { padding: var(--s4); }
}
@media (max-width: 560px) {
  .hero-row .tiles { grid-template-columns: 1fr 1fr; }
  .hero-value { font-size: 38px; }
  .filters { width: 100%; }
}
.btn.tiny { min-height: 26px; padding: 0 var(--s2); font-size: var(--fs-label); }
.hero-figure .tile-label { font-size: var(--fs-small); color: var(--text-soft); }
.hero-figure .tile-note { font-size: var(--fs-label); color: var(--text-soft); display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.tile .tile-note .delta { margin-right: 2px; }
.row.nowrap { flex-wrap: nowrap; }
.customers-table .row.tight { align-items: center; }
@media (max-width: 560px) {
  .mcard { padding: 16px 18px; border-radius: 18px; }
  .mcard-brand { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mcard-tier { font-size: 10px; padding: 4px 8px; }
  .mcard-name { font-size: 18px; }
  .mcard-no { font-size: 15px; white-space: nowrap; letter-spacing: .04em; }
  .mcard-qr svg { width: 70px; height: 70px; }
}
.guide > *, .guide-body, .guide-section, .endpoint { min-width: 0; }
.guide-toc a { white-space: nowrap; flex: none; }
