/* ==========================================================================
   Accounting P&L — interactive demo
   Namespaced with .accx-* to avoid colliding with the legacy .acc-* rules.
   ========================================================================== */

.accx-stage {
  position: relative;
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 1;
}

/* ---------- Main card ---------- */
.accx-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px 22px 20px;
  overflow: hidden;
}

.accx-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(42, 40, 119, 0.025), transparent 40%);
}

/* Title row */
.accx-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.accx-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.accx-title .accx-cal {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--navy-50);
  color: var(--navy);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.accx-title .accx-cal [data-lucide] {
  width: 14px;
  height: 14px;
}

.accx-title .accx-sub {
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  margin-left: 2px;
}

.accx-help {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all .18s;
}

.accx-help:hover {
  color: var(--navy);
  border-color: var(--navy);
  background: var(--navy-50);
}

.accx-help [data-lucide] {
  width: 12px;
  height: 12px;
}

.accx-help .accx-tip {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 190px;
  max-width: 220px;
  padding: 8px 10px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 5;
  text-align: left;
}

.accx-help:hover .accx-tip,
.accx-help:focus .accx-tip {
  opacity: 1;
  transform: translateY(0);
}

/* Replay button (top-right of card) */
.accx-replay {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .25s, transform .25s, background .18s, color .18s;
  z-index: 4;
}

.accx-replay.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.accx-replay:hover {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.accx-replay [data-lucide] {
  width: 12px;
  height: 12px;
}

/* ---------- Segmented toggle ---------- */
.accx-seg {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: var(--navy-50);
  border: 1px solid rgba(42, 40, 119, 0.08);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 18px;
}

.accx-seg-btn {
  position: relative;
  z-index: 2;
  background: none;
  border: none;
  padding: 7px 6px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-radius: 7px;
  letter-spacing: -0.01em;
  transition: color .22s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
}

.accx-seg-btn:hover:not(.act) {
  color: var(--ink-2);
}

.accx-seg-btn.act {
  color: var(--navy);
}

.accx-seg-btn [data-lucide] {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.accx-seg-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  bottom: 3px;
  width: calc((100% - 6px) / 3);
  background: #fff;
  border-radius: 7px;
  box-shadow: 0 1px 3px rgba(42, 40, 119, 0.1), 0 1px 1px rgba(0, 0, 0, 0.04);
  transition: transform .32s cubic-bezier(.4, .0, .2, 1);
  z-index: 1;
}

/* ---------- P&L rows ---------- */
.accx-rows {
  display: flex;
  flex-direction: column;
}

.accx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
  color: var(--ink-2);
  transition: background .2s;
}

.accx-row-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.accx-row-label .accx-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.accx-row.income .accx-dot { background: var(--green); }
.accx-row.expense .accx-dot { background: var(--orange); }
.accx-row.returns .accx-dot { background: var(--red); }

.accx-val {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  transition: color .2s;
}

.accx-row.expense .accx-val,
.accx-row.returns .accx-val {
  color: var(--red);
}

.accx-row.income .accx-val {
  color: var(--ink);
}

/* Flash highlight when a live order bumps the gross */
.accx-val.flash-up {
  color: var(--green) !important;
  transition: color .15s;
}

.accx-val.flash-down {
  color: var(--red) !important;
  transition: color .15s;
}

/* Net profit — the climax row */
.accx-divider {
  height: 10px;
}

.accx-row.net {
  padding: 14px 0 4px;
  border-top: 2px solid var(--ink);
  border-bottom: none;
  margin-top: 2px;
}

.accx-row.net .accx-row-label {
  font-size: 14px;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.015em;
}

.accx-row.net .accx-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.02em;
}

/* Margin pill beside net profit */
.accx-net-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0 0;
}

.accx-margin {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 999px;
  letter-spacing: -0.005em;
  transition: background .22s, color .22s;
}

.accx-margin.pos {
  background: var(--green-50);
  color: var(--green);
}

.accx-margin.neg {
  background: var(--red-50);
  color: var(--red);
}

.accx-margin [data-lucide] {
  width: 12px;
  height: 12px;
}

.accx-margin-note {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

/* Pop animation on net profit when it lands */
.accx-row.net.pop .accx-val {
  animation: accx-pop .5s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes accx-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* ---------- Live orders ticker strip ---------- */
.accx-ticker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px 10px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.accx-ticker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.accx-ticker-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.accx-ticker-title [data-lucide] {
  width: 12px;
  height: 12px;
}

.accx-ticker-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.accx-ticker-live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55);
  animation: accx-pulse 1.6s infinite;
}

@keyframes accx-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.accx-ticker-list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 46px;
}

.accx-ticker-empty {
  font-size: 11.5px;
  color: var(--muted);
  font-style: italic;
  padding: 6px 2px;
}

.accx-tick {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  opacity: 0;
  transform: translateY(8px);
  animation: accx-tick-in .38s cubic-bezier(.2, .8, .2, 1) forwards;
  transition: opacity .5s, transform .5s;
}

.accx-tick.leaving {
  animation: accx-tick-out .5s cubic-bezier(.4, 0, .2, 1) forwards;
}

@keyframes accx-tick-in {
  0%   { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes accx-tick-out {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-10px); }
}

.accx-tick-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.accx-tick.ok .accx-tick-icon {
  background: var(--green-50);
  color: var(--green);
}

.accx-tick.refund .accx-tick-icon {
  background: var(--red-50);
  color: var(--red);
}

.accx-tick-icon [data-lucide] {
  width: 12px;
  height: 12px;
}

.accx-tick-amt {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -0.01em;
  min-width: 62px;
}

.accx-tick.ok .accx-tick-amt    { color: var(--green); }
.accx-tick.refund .accx-tick-amt { color: var(--red); }

.accx-tick-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.accx-tick-top {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.accx-tick-top .accx-tick-id {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  color: var(--muted);
  margin-right: 6px;
  font-size: 11px;
}

.accx-tick-status {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.accx-tick.ok .accx-tick-status    { color: var(--green); }
.accx-tick.refund .accx-tick-status { color: var(--red); }

/* ---------- responsive-ish ---------- */
@media (max-width: 520px) {
  .accx-seg-btn { font-size: 10.5px; padding: 7px 4px; gap: 3px; }
  .accx-row.net .accx-val { font-size: 18px; }
  .accx-card { padding: 18px 16px 16px; }
}
