/* Levels: the settings, the level-ups, one customer's levels in the drawer and the Level card on the
   customer record. Tokens only, so light and dark both follow tokens.css. No style is set from the
   page's script: the bars are <progress> elements, styled here. */

.lv-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.lv-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.lv-side { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.lv-card { overflow: hidden; }
.lv-card > .card-head + .switches { border-top: 0; }

/* The switches, and the line under them saying when levels started. */
.lv-status { margin: 0; padding: 10px 18px; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); background: var(--panel-2); border-top: 1px solid var(--line); }
.lv-status strong { font-weight: 600; color: var(--ink); }
.lv-status.on strong { color: var(--ok); }

/* A box for a figure, with its unit after it. */
.lv-in { display: flex; align-items: center; gap: 6px; min-width: 0; height: 32px; padding: 0 9px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.lv-in:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lv-in.bad { border-color: var(--crit); }
.lv-in input { flex: 1; width: 100%; min-width: 0; padding: 0; color: var(--ink); background: none; border: 0; outline: 0; font: inherit; font-family: var(--mono); font-size: 13px; text-align: right; }
.lv-in input::placeholder { color: var(--ink-3); }
.lv-unit { flex: none; font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.lv-said { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--crit); }
.lv-said[hidden] { display: none; }

/* XP from money: the rate, then one row per money action. */
.lv-rate { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.lv-rate-k { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 200px; font-weight: 500; }
.lv-rate-f { font-size: 12px; font-weight: 400; color: var(--ink-3); }
.lv-rate .lv-in { flex: none; width: 104px; }
.lv-rate .lv-said { flex-basis: 100%; }

.lv-rows { display: flex; flex-direction: column; }
.lv-mrow {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 84px minmax(0, 1.5fr) 72px;
  grid-template-areas: "act boost ex back" "said said said said";
  align-items: center;
  column-gap: 14px;
  padding: 10px 18px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.lv-mrow:last-child { border-bottom: 0; }
.lv-row-head { padding-top: 8px; padding-bottom: 8px; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); background: var(--panel-2); }
.lv-m-act { display: flex; flex-direction: column; gap: 2px; grid-area: act; min-width: 0; }
.lv-m-name { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-weight: 500; }
.lv-row-head .lv-m-act { font-weight: 600; }
.lv-m-boost { grid-area: boost; }
.lv-m-ex { display: flex; flex-direction: column; gap: 2px; grid-area: ex; min-width: 0; color: var(--ink-2); }
.lv-m-back { grid-area: back; text-align: right; }
.lv-mrow > .lv-said { grid-area: said; margin-top: 6px; }
.lv-mrow.warn { background: var(--warn-soft); }
.lv-mrow.warn > .lv-said { color: var(--warn); }
.lv-mrow.crit { background: var(--crit-soft); }

.lv-boost { display: inline-flex; align-items: center; padding: 0 7px; font-size: 10.5px; font-weight: 700; line-height: 17px; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); border-radius: 99px; }
.lv-boost[hidden] { display: none; }
.lv-back { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.lv-back.warn { font-weight: 600; color: var(--warn); }
.lv-back.crit { font-weight: 600; color: var(--crit); }

/* One-time XP. */
.lv-orow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  grid-template-areas: "k in" "said said";
  align-items: center;
  column-gap: 14px;
  padding: 9px 18px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.lv-orow:last-child { border-bottom: 0; }
.lv-o-k { display: flex; flex-direction: column; gap: 2px; grid-area: k; min-width: 0; }
.lv-orow > .lv-in { grid-area: in; }
.lv-orow > .lv-said { grid-area: said; margin-top: 6px; }
.lv-orow.crit { background: var(--crit-soft); }
.lv-total { margin: 0; padding: 11px 18px; font-size: 13px; color: var(--ink-2); background: var(--panel-2); border-top: 1px solid var(--line); }
.lv-total strong { font-weight: 600; color: var(--ink); }

/* The fifty levels: tools above, a tier head over each tier's rows, the sum under them. */
.lv-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px; }
.lv-every { margin-left: auto; }
.lv-problems { display: flex; flex-direction: column; gap: 8px; padding: 0 18px 12px; }
.lv-problems:empty { display: none; }
.lv-levels { border-top: 1px solid var(--line); }
.lv-levels th, .lv-levels td { padding: 6px 14px; }
.lv-levels th:first-child, .lv-levels td:first-child { padding-left: 18px; }
.lv-levels th:last-child, .lv-levels td:last-child { padding-right: 18px; }
.lv-levels thead th { padding-top: 9px; padding-bottom: 9px; }
.lv-levels td.lv-c-reward { width: 1%; }
.lv-levels .lv-in { width: 118px; height: 30px; }
.lv-levels tr.lv-tier th { padding: 0; font-size: 13px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--ink); border-top: 1px solid var(--line); }
.lv-levels tbody tr.lv-tier:first-child th { border-top: 0; }
.lv-levels tr.lv-up td { background: var(--accent-soft); }
.lv-levels tr.warn td { background: var(--warn-soft); }
.lv-levels tr.crit td { background: var(--crit-soft); }
.lv-lv-n { font-weight: 600; font-variant-numeric: tabular-nums; }
.lv-chip { display: inline-block; margin-left: 8px; padding: 0 7px; font-size: 10.5px; font-weight: 700; line-height: 17px; letter-spacing: .04em; text-transform: uppercase; vertical-align: 1px; color: var(--accent); background: var(--panel); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 99px; }
.lv-xp { align-items: flex-end; }
.lv-xp-fees { display: none; }
.lv-start { font-size: 12px; }

.lv-tier-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 18px; font: inherit; font-size: 13px; text-align: left; color: var(--ink); background: none; border: 0; cursor: pointer; }
.lv-tier-btn:hover { background: var(--panel-3); }
.lv-tier-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.lv-chev { width: 14px; height: 14px; color: var(--ink-3); transition: transform .12s; }
.lv-tier-btn[aria-expanded="false"] .lv-chev { transform: rotate(-90deg); }
.lv-tier-t { font-weight: 600; }
.lv-tier-f { margin-left: auto; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.lv-tier-act { min-width: 34px; font-size: 12px; font-weight: 600; text-align: right; color: var(--accent); }
.lv-sum { margin: 0; padding: 12px 18px; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); background: var(--panel-2); border-top: 1px solid var(--line); }
.lv-sum strong { font-weight: 600; color: var(--ink); }

/* The side: what the rewards pay back, and how many customers are in each tier. */
.lv-big { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 14px 16px 4px; }
.lv-big-v { font-size: 30px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.lv-big-u { font-size: 13px; color: var(--ink-3); }
.lv-big-f { flex-basis: 100%; font-size: 12.5px; font-weight: 600; color: var(--ok); }
.lv-big-f.warn { color: var(--warn); }
.lv-sums { display: grid; grid-template-columns: minmax(0, 1fr) auto; margin: 8px 0 8px; padding: 0 16px; font-size: 13px; }
.lv-sums dt, .lv-sums dd { margin: 0; padding: 7px 0; color: var(--ink-2); border-top: 1px solid var(--line); }
.lv-sums dd { padding-left: 12px; text-align: right; white-space: nowrap; color: var(--ink); font-variant-numeric: tabular-nums; }
.lv-sums dd.warn { font-weight: 600; color: var(--warn); }
.lv-sums dd.crit { font-weight: 600; color: var(--crit); }

.lv-tiers { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.lv-tier-row { display: grid; grid-template-columns: 84px minmax(40px, 1fr) 48px; align-items: center; gap: 10px; font-size: 13px; }
.lv-tier-k { display: flex; flex-direction: column; font-weight: 500; }
.lv-tier-n { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.lv-bar { display: block; width: 100%; height: 8px; overflow: hidden; color: var(--accent); background: var(--panel-3); border: 0; border-radius: 99px; appearance: none; -webkit-appearance: none; }
.lv-bar::-webkit-progress-bar { background: var(--panel-3); border-radius: 99px; }
.lv-bar::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
.lv-bar::-moz-progress-bar { background: var(--accent); border-radius: 99px; }
.lv-paid { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 11px 16px; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); background: var(--panel-2); border-top: 1px solid var(--line); }
.lv-paid strong { font-weight: 600; color: var(--ink); }

/* Level-ups: the level with its tier beside it. */
.lv-lvcell { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lv-tierchip { padding: 0 7px; font-size: 11px; font-weight: 600; line-height: 18px; color: var(--ink-2); background: var(--panel-3); border-radius: 99px; }

/* One customer, in the drawer. */
.lv-where { display: flex; flex-direction: column; gap: 6px; }
.lv-where-t { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.lv-where-xp { margin: 0; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lv-bar-big { height: 10px; margin-top: 4px; }
.lv-where-f { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; margin: 0; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lv-where-r { color: var(--ink-3); }
.lv-hist { display: flex; flex-direction: column; }
.lv-h { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 7px 0; font-size: 13px; border-top: 1px solid var(--line); }
.lv-h:first-child { border-top: 0; }
.lv-h-at { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
.lv-h-xp { font-weight: 600; text-align: right; color: var(--ok); font-variant-numeric: tabular-nums; }
.lv-h-xp.minus { color: var(--crit); }
.lv-h-v { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; font-variant-numeric: tabular-nums; }
.lv-none { margin: 0; padding: 7px 0; font-size: 13px; color: var(--ink-3); }

/* One customer's level, on their record: the figures, the bar into the level, the latest XP. */
.lv-card-bar { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-top: 1px solid var(--line); }
.lv-card-bar .lv-bar-big { margin-top: 0; }
.lv-card-hist { padding: 10px 14px 6px; border-top: 1px solid var(--line); }
.lv-card-k { margin: 0 0 2px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }

/* Not saved yet: held at the bottom of the screen while anything differs from what is saved. */
.lv-unsaved { position: sticky; bottom: 12px; z-index: 5; display: flex; align-items: center; gap: 10px 14px; margin-top: 16px; padding: 10px 12px 10px 16px; background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.lv-unsaved[hidden] { display: none; }
.lv-unsaved-t { flex: 1; min-width: 0; font-size: 13.5px; color: var(--ink-2); }
.lv-unsaved-t strong { color: var(--accent); }
.lv-unsaved-act { display: flex; flex: none; gap: 8px; }

/* Under 1240px the side has no room beside the levels table, so it goes under the cards. */
@media (max-width: 1240px) {
  .lv-layout { grid-template-columns: minmax(0, 1fr); }
  .lv-side { position: static; }
}

@media (max-width: 640px) {
  .lv-rate, .lv-tools { padding-left: 14px; padding-right: 14px; }
  .lv-status, .lv-total, .lv-sum { padding-left: 14px; padding-right: 14px; }
  .lv-problems { padding: 0 14px 12px; }
  .lv-every { margin-left: 0; }

  .lv-mrow { grid-template-columns: minmax(0, 1fr) 104px; grid-template-areas: "act boost" "ex back" "said said"; row-gap: 8px; padding: 10px 14px; }
  .lv-row-head { display: none; }
  .lv-m-back { white-space: nowrap; }
  .lv-m-back::before { content: "paid back "; font-size: 12px; color: var(--ink-3); }
  .lv-orow { grid-template-columns: minmax(0, 1fr) 92px; padding: 9px 14px; }

  .lv-levels thead th { white-space: normal; vertical-align: bottom; }
  .lv-levels th, .lv-levels td { padding-left: 7px; padding-right: 7px; }
  .lv-levels th:first-child, .lv-levels td:first-child { padding-left: 14px; }
  .lv-levels th:last-child, .lv-levels td:last-child { padding-right: 14px; }
  .lv-levels .lv-in { width: 72px; }
  .lv-start { display: inline-block; max-width: 72px; white-space: normal; }
  .lv-levels .lv-unit { display: none; }
  .lv-c-fees { display: none; }
  .lv-xp-fees { display: block; font-size: 11.5px; color: var(--ink-3); }
  /* The row's colour and the tier head right above it already say it; the chip has no room here. */
  .lv-chip { display: none; }
  .lv-tier-btn { flex-wrap: wrap; padding: 9px 14px; }
  .lv-tier-f { flex-basis: 100%; order: 3; margin-left: 22px; }
  .lv-tier-act { margin-left: auto; }

  .lv-unsaved { flex-wrap: wrap; }
  .lv-unsaved-t { flex-basis: 100%; }
  .lv-unsaved-act { flex: 1; justify-content: flex-end; }
  .lv-h { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; }
  .lv-h-at { grid-column: 1 / -1; }
}
