/* Coil — operator console.
   Palette from the subject's materials: card sleeves, cabinet steel, holo foil.
   Depth comes from three real surface levels plus one recessed cabinet well,
   so the machine reads as an object rather than a flat panel. */

:root {
  /* four surface levels, not two - this is what kills the flatness */
  --void:       #0B0910;   /* page floor */
  --ink:        #0F0D16;   /* body */
  --sleeve:     #17141F;   /* raised card */
  --sleeve-2:   #201C2B;   /* hover / inner chip */
  --well:       #08070C;   /* recessed cabinet interior */

  --line:       #2A2438;
  --line-soft:  #201B2C;
  --edge:       rgba(255, 255, 255, .055);   /* top highlight on raised cards */

  --stock:      #EFEDF5;
  --stock-dim:  #A49CBA;
  --stock-mute: #6E6689;

  --foil-a:     #FF4D9D;
  --foil-b:     #4DE1FF;
  --low:        #FFB020;
  --fault:      #FF5C7A;
  --good:       #4DE1FF;

  --r:          14px;
  --r-sm:       9px;
  --pad:        clamp(16px, 4vw, 30px);

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body:    "Instrument Sans", ui-sans-serif, system-ui, sans-serif;
  --mono:    "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--ink); color: var(--stock);
  font-family: var(--body); -webkit-font-smoothing: antialiased; }

body {
  min-height: 100vh;
  background-image:
    radial-gradient(120ch 70ch at 8% -15%, rgba(255, 77, 157, .10), transparent 62%),
    radial-gradient(90ch 60ch at 100% 0%, rgba(77, 225, 255, .075), transparent 60%),
    linear-gradient(180deg, var(--ink) 0%, var(--void) 90%);
  background-attachment: fixed;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px var(--pad);
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(15, 13, 22, .78);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line-soft);
}

.topbar__id { display: flex; align-items: center; gap: 9px; min-width: 0; }
.topbar__acts { display: flex; gap: 7px; flex: none; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--stock-mute); flex: none; }
.dot.is-online  { background: var(--good);  box-shadow: 0 0 0 3px rgba(77, 225, 255, .15); }
.dot.is-offline { background: var(--fault); box-shadow: 0 0 0 3px rgba(255, 92, 122, .15); }

.eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: .09em;
  text-transform: uppercase; color: var(--stock-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ghostbtn {
  background: none; border: 1px solid var(--line); color: var(--stock-mute);
  border-radius: 7px; padding: 6px 11px; cursor: pointer;
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
}
.ghostbtn:hover { color: var(--stock); border-color: var(--stock-mute); }
.ghostbtn:focus-visible { outline: 2px solid var(--foil-b); outline-offset: 2px; }

/* ---------- layout ---------- */

.wrap {
  max-width: 1180px; margin: 0 auto;
  padding: clamp(20px, 4vw, 34px) var(--pad) calc(72px + env(safe-area-inset-bottom));
  display: grid; gap: clamp(18px, 3vw, 26px);
}

/* raised surface, used by every card */
.panel, .ledger, .coil {
  background: linear-gradient(180deg, var(--sleeve), #141220);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 1px 0 var(--edge) inset, 0 24px 50px -40px rgba(0, 0, 0, .95);
}

/* ---------- ledger: the money, the week, the facts ---------- */

.ledger {
  display: grid;
  gap: 0;
  grid-template-columns: 1fr;
  overflow: hidden;
}
@media (min-width: 800px) {
  .ledger { grid-template-columns: minmax(240px, .85fr) 1.15fr; }
  .ledger__facts { grid-column: 1 / -1; }
}

.ledger__take {
  padding: clamp(20px, 3vw, 28px);
  display: grid; align-content: center; gap: 4px;
  border-bottom: 1px solid var(--line-soft);
}
@media (min-width: 800px) {
  .ledger__take { border-bottom: 0; border-right: 1px solid var(--line-soft); }
}

.ledger__label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--stock-mute);
}

.ledger__value {
  font-family: var(--mono); font-weight: 700;
  font-size: clamp(38px, 8vw, 58px); line-height: .95;
  letter-spacing: -.03em; font-variant-numeric: tabular-nums;
  background: linear-gradient(96deg, var(--stock) 30%, var(--foil-b));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.ledger__sub { font-size: 13px; color: var(--stock-dim); }
.ledger__sub b { color: var(--stock); font-weight: 600; }

.ledger__week { padding: clamp(18px, 3vw, 24px); display: grid; gap: 14px; align-content: start; }

.ledger__weekhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }

.ledger__weektotal {
  font-family: var(--mono); font-size: 14px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* seven bars, same vocabulary as the lanes */
.spark { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 84px; }

.spark__day { display: grid; gap: 6px; justify-items: center; align-content: end; height: 100%; }

.spark__bar {
  width: 100%; border-radius: 3px 3px 2px 2px;
  background: linear-gradient(180deg, rgba(77, 225, 255, .55), rgba(255, 77, 157, .35));
  min-height: 3px;
  transition: height .5s cubic-bezier(.22, 1, .36, 1);
  position: relative;
}
.spark__day--today .spark__bar {
  background: linear-gradient(180deg, var(--foil-b), var(--foil-a));
  box-shadow: 0 0 18px -4px var(--foil-b);
}

.spark__tag {
  font-family: var(--mono); font-size: 9px; letter-spacing: .08em;
  color: var(--stock-mute); text-transform: uppercase;
}
.spark__day--today .spark__tag { color: var(--stock); }

.ledger__facts {
  display: grid; grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--line-soft);
}
@media (min-width: 620px) { .ledger__facts { grid-template-columns: repeat(4, 1fr); } }

.fact {
  padding: 14px clamp(14px, 2vw, 20px);
  border-right: 1px solid var(--line-soft);
  display: grid; gap: 5px;
}
.fact:last-child { border-right: 0; }
@media (max-width: 619px) { .fact:nth-child(2n) { border-right: 0; } }

.fact__label {
  font-family: var(--mono); font-size: 9px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--stock-mute);
}
.fact__value {
  font-family: var(--mono); font-size: 17px; font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.fact__value--warn { color: var(--low); }
.fact__hint { font-size: 11.5px; color: var(--stock-dim); }

/* ---------- the coil ---------- */

.coil { padding: clamp(18px, 3vw, 26px); }

.coil__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}

.coil__title {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(26px, 4.6vw, 38px); line-height: .98;
  letter-spacing: -.025em; margin: 0 0 5px;
}

.coil__sub { margin: 0; font-size: 13.5px; color: var(--stock-dim); max-width: 48ch; }

.coil__fill { text-align: right; flex: none; }
.coil__fillnum {
  display: block; font-family: var(--mono); font-weight: 700;
  font-size: clamp(20px, 3vw, 26px); font-variant-numeric: tabular-nums;
  color: var(--foil-b); line-height: 1;
}
.coil__filllabel {
  font-family: var(--mono); font-size: 9px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--stock-mute);
}

/* recessed cabinet: the lanes sit *inside* something */
.cabinet {
  background: var(--well);
  border: 1px solid #241E33;
  border-radius: 11px;
  padding: clamp(12px, 2vw, 18px);
  box-shadow:
    0 12px 30px -18px rgba(0, 0, 0, .9) inset,
    0 1px 0 rgba(255, 255, 255, .03);
}

.coil__grid { display: grid; gap: 11px; }
.loading { font-family: var(--mono); font-size: 12px; color: var(--stock-mute); margin: 0; }

.layer { display: grid; grid-template-columns: 30px 1fr; align-items: end; gap: 11px; }

.layer__tag {
  font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: .05em;
  color: var(--stock-mute); padding-bottom: 21px;
}

.layer__lanes {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  gap: clamp(4px, 1vw, 9px); align-items: end;
}

.lane {
  appearance: none; border: 0; background: none; padding: 0; cursor: pointer;
  display: grid; gap: 6px; justify-items: center; color: inherit; font: inherit;
}

.lane__track {
  position: relative; width: 100%;
  height: clamp(66px, 14vw, 96px);
  border-radius: 4px;
  background: #120F1B;
  border: 1px solid #2B2440;
  overflow: hidden;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.lane:hover .lane__track, .lane:focus-visible .lane__track {
  transform: translateY(-4px);
  border-color: var(--stock-mute);
  box-shadow: 0 10px 20px -12px rgba(0, 0, 0, .9);
}
.lane:focus-visible { outline: none; }
.lane:focus-visible .lane__track { box-shadow: 0 0 0 2px var(--foil-b); }

.lane__fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0;
  transition: height .6s cubic-bezier(.22, 1, .36, 1);
}

.lane--ok .lane__fill {
  background: linear-gradient(0deg, var(--foil-a), var(--foil-b));
  box-shadow: 0 0 14px -2px rgba(77, 225, 255, .5);
}
.lane--low .lane__fill { background: linear-gradient(0deg, #C97A00, var(--low)); }
.lane--fault .lane__fill {
  background: repeating-linear-gradient(45deg,
    var(--fault) 0 5px, rgba(255, 92, 122, .5) 5px 10px);
}
.lane--empty .lane__track { border-style: dashed; border-color: #3A3350; }

.lane__code {
  font-family: var(--mono); font-size: 9.5px; color: var(--stock-mute);
  font-variant-numeric: tabular-nums;
}
.lane--fault .lane__code, .lane--empty .lane__code { color: var(--stock-dim); }

.legend {
  display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 16px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--stock-mute);
}
.legend__item { display: inline-flex; align-items: center; gap: 7px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw--ok { background: linear-gradient(0deg, var(--foil-a), var(--foil-b)); }
.sw--low { background: var(--low); }
.sw--empty { border: 1px dashed #3A3350; }
.sw--fault { background: var(--fault); }

/* ---------- panels ---------- */

.cols { display: grid; gap: clamp(18px, 3vw, 26px); }
@media (min-width: 800px) { .cols { grid-template-columns: 1fr 1fr; } }

.panel { padding: 16px 16px 12px; }
.panel--alert { border-color: #3A2B3F; }

.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px; padding: 0 4px;
}

.panel__title {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase; color: var(--stock-dim); margin: 0;
}

.pill {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(255, 92, 122, .14); color: var(--fault);
  border: 1px solid rgba(255, 92, 122, .3);
}
.pill--quiet { background: none; color: var(--stock-mute); border-color: var(--line); }
.pill--calm { background: rgba(77, 225, 255, .12); color: var(--foil-b); border-color: rgba(77, 225, 255, .3); }

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.row {
  display: grid; grid-template-columns: 40px 1fr auto;
  align-items: center; gap: 12px;
  padding: 10px 8px; border-radius: var(--r-sm);
  width: 100%; border: 0; background: none; color: inherit; font: inherit;
  text-align: left; cursor: pointer;
  transition: background .14s ease;
}
.row:hover { background: var(--sleeve-2); }
.row:focus-visible { outline: 2px solid var(--foil-b); outline-offset: -2px; }
.row--static { cursor: default; }
.row--static:hover { background: none; }

.row__code {
  font-family: var(--mono); font-size: 11.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.row__code--ok    { color: var(--foil-b); }
.row__code--low   { color: var(--low); }
.row__code--empty { color: var(--stock-dim); }
.row__code--fault { color: var(--fault); }

.rank {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  color: var(--stock-mute); text-align: center;
}

.row__main { min-width: 0; }
.row__name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__meta { font-size: 12px; color: var(--stock-dim); margin-top: 2px; }

.row__right {
  font-family: var(--mono); font-size: 12px; color: var(--stock-dim);
  font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap;
}
.row__right b { color: var(--stock); font-weight: 700; }

/* share bar behind the top-sellers rows */
.row--bar { position: relative; overflow: hidden; }
.row--bar::before {
  content: ""; position: absolute; inset: 0 auto 0 0;
  width: var(--share, 0%);
  background: linear-gradient(90deg, rgba(77, 225, 255, .16), rgba(255, 77, 157, .05));
  border-radius: var(--r-sm);
  pointer-events: none;
}
.row--bar > * { position: relative; }

.tag {
  display: inline-block; font-family: var(--mono); font-size: 9px;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 5px; border-radius: 3px; border: 1px solid var(--line);
  color: var(--stock-dim); margin-left: 6px; vertical-align: 1px;
}
.tag--app { border-color: rgba(77, 225, 255, .4); color: var(--foil-b); }
.tag--failed { border-color: rgba(255, 92, 122, .45); color: var(--fault); }

.empty-note { font-size: 13px; color: var(--stock-mute); margin: 6px 8px 10px; }

/* ---------- lane sheet ---------- */

.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet[hidden] { display: none; }
.sheet__scrim { position: absolute; inset: 0; background: rgba(6, 5, 9, .72); backdrop-filter: blur(2px); }

.sheet__card {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, var(--sleeve), #131120);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 20px var(--pad) calc(24px + env(safe-area-inset-bottom));
  display: grid; gap: 16px; max-height: 88vh; overflow-y: auto;
  animation: rise .22s cubic-bezier(.22, 1, .36, 1);
}

@media (min-width: 620px) {
  .sheet__card {
    left: 50%; bottom: auto; top: 50%; right: auto;
    transform: translate(-50%, -50%);
    width: min(440px, 92vw);
    border: 1px solid var(--line); border-radius: var(--r);
    animation: pop .2s cubic-bezier(.22, 1, .36, 1);
    box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .95);
  }
}

@keyframes rise { from { transform: translateY(14px); opacity: .6; } }
@keyframes pop  { from { transform: translate(-50%, -48%); opacity: .6; } }

.sheet__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.sheet__code {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  letter-spacing: .07em; color: var(--foil-b); display: block;
}
.sheet__product {
  font-family: var(--display); font-weight: 700; font-size: 22px;
  letter-spacing: -.015em; display: block; margin-top: 4px;
}

.iconbtn {
  background: none; border: 1px solid var(--line); color: var(--stock-dim);
  width: 30px; height: 30px; border-radius: 7px; cursor: pointer; flex: none;
  font-size: 12px; line-height: 1;
}
.iconbtn:hover { color: var(--stock); border-color: var(--stock-mute); }

.kv {
  margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 7px 14px;
  font-size: 13px; padding: 13px 0;
  border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
}
.kv dt {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .11em;
  text-transform: uppercase; color: var(--stock-mute); align-self: center;
}
.kv dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.kv .warn { color: var(--fault); }

.field { display: grid; gap: 7px; }
.field__label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .11em;
  text-transform: uppercase; color: var(--stock-mute);
}
.field__row { display: flex; gap: 8px; }

.input {
  flex: 1; min-width: 0; background: var(--well);
  border: 1px solid var(--line); color: var(--stock);
  border-radius: 8px; padding: 11px 12px;
  font-family: var(--mono); font-size: 16px; font-variant-numeric: tabular-nums;
}
.input:focus { outline: 2px solid var(--foil-b); outline-offset: -1px; border-color: transparent; }

.btn {
  background: var(--sleeve-2); border: 1px solid var(--line); color: var(--stock);
  border-radius: 8px; padding: 11px 14px;
  font-family: var(--body); font-size: 14px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--stock-mute); }
.btn:focus-visible { outline: 2px solid var(--foil-b); outline-offset: 2px; }
.btn[disabled] { opacity: .5; cursor: default; }

.btn--primary { background: var(--stock); color: var(--ink); border-color: var(--stock); font-weight: 600; }
.btn--primary:hover { background: #fff; }
.btn--ghost { background: none; color: var(--stock-dim); }
.btn--ghost:hover { color: var(--stock); }

.sheet__note { margin: -8px 0 0; font-size: 12px; color: var(--stock-mute); }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: var(--stock); color: var(--ink);
  padding: 11px 16px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 60; max-width: calc(100vw - 32px); text-align: center;
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, .9);
}
.toast.is-up { opacity: 1; transform: translate(-50%, 0); }
.toast.is-bad { background: var(--fault); color: #fff; }

/* sign out lives quietly in the top bar */
.signout {
  background: none; border: 1px solid var(--line); color: var(--stock-mute);
  border-radius: 7px; padding: 5px 10px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; cursor: pointer; margin-left: 12px;
}
.signout:hover { color: var(--stock); border-color: var(--stock-mute); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
