/* Energy Buddy v2 · projector stage. Designed at 1920×1080, scaled to fit any screen.
   Colours for blue / amber / white / green / grey / navy come from config.js (set by app.js).
   Views: body.view-split (default) · body.view-renter (key R) · body.view-partner (key P). */
:root {
  --blue: #4DA3FF;
  --amber: #EFA34A;
  --white: #FFFFFF;
  --green: #3DDC84;
  --grey: #7D8A92;
  --navy: #173845;
  --red: #FF6B5E;
  --bg: #0A1A21;
  --bg-deep: #050E12;
  --phone: #0E242D;
  --panel-2: #0F2A34;
  --text: #F2F7F9;
  --muted: #9FB6C0;
  --line: rgba(255, 255, 255, 0.10);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg-deep); overflow: hidden; }
body { font-family: var(--font); color: var(--text); -webkit-font-smoothing: antialiased; }
body.hide-cursor { cursor: none; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-weight: 500; }
button { font-family: inherit; }

#stage {
  position: absolute; left: 0; top: 0; width: 1920px; height: 1080px;
  transform-origin: 0 0; background: var(--bg); overflow: hidden;
}

/* ------------------------------------------------------------------ top bar */
#top {
  position: absolute; left: 0; right: 0; top: 0; height: 84px; padding: 0 44px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 16px; font-size: 32px; font-weight: 750; letter-spacing: -0.01em; }
.logo { width: 52px; height: 40px; border-radius: 12px; background: var(--navy); border: 2px solid rgba(255,255,255,.25); display: grid; place-items: center; }
.logo i { width: 30px; height: 11px; border-radius: 6px; background: var(--amber); }

.simclock { display: flex; align-items: center; gap: 14px; font-size: 30px; font-weight: 600; white-space: nowrap; }
.sim-tag { font-size: 20px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; padding: 5px 12px; border-radius: 8px; border: 2px solid var(--muted); color: var(--muted); }
#simLine, .sep { color: var(--muted); }
#clock { font-weight: 800; min-width: 128px; }
#evTag { font-size: 24px; font-weight: 800; padding: 6px 16px; border-radius: 999px; background: var(--amber); color: #2A1A05; display: none; }
#evTag.on { display: inline-block; }

#badge { justify-self: end; display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 700; padding: 9px 20px; border-radius: 999px; border: 2px solid var(--line); color: var(--muted); }
#badge i { width: 14px; height: 14px; border-radius: 50%; background: var(--muted); }
#badge.live { color: var(--text); border-color: rgba(61, 220, 132, .45); }
#badge.live i { background: var(--green); box-shadow: 0 0 12px var(--green); }
#badge.demo { color: #2A1A05; background: var(--amber); border-color: var(--amber); }
#badge.demo i { background: #2A1A05; animation: blink 1.4s infinite; }
#badge.connecting i { animation: blink .9s infinite; }
#badge.nobox { color: var(--muted); }
#badge.nobox i { background: var(--muted); }
body.no-box .needs-box { display: none !important; }
@keyframes blink { 50% { opacity: .25; } }

/* ------------------------------------------------------------------ behind-the-scenes strip */
#pathbar {
  position: absolute; left: 44px; right: 44px; top: 96px; height: 60px;
  display: flex; align-items: center; gap: 22px; padding: 0 12px 0 22px;
  border-radius: 18px; background: var(--panel-2); border: 1px solid var(--line);
}
.path-tag { flex: none; font-size: 15px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); width: 128px; line-height: 1.2; }
.path { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.node {
  flex: 1; min-width: 0; height: 44px; display: flex; align-items: center; justify-content: center; gap: 10px;
  border-radius: 12px; border: 2px solid var(--line); color: var(--muted); font-size: 22px; font-weight: 700; white-space: nowrap;
  transition: background-color .35s, border-color .35s, color .35s;
}
.node i { flex: none; width: 12px; height: 12px; border-radius: 50%; background: currentColor; opacity: .5; }
.node.lit { background: rgba(239,163,74,.16); border-color: rgba(239,163,74,.7); color: var(--amber); }
.node.lit i { opacity: 1; box-shadow: 0 0 10px currentColor; }
.node.lit.pop { animation: nodePop .5s ease-out; }
@keyframes nodePop { 0% { transform: scale(1.06); } 100% { transform: none; } }
.node.confirmed { color: var(--text); border-color: var(--white); background: rgba(255,255,255,.12); }
.node.back { color: var(--text); border-color: rgba(255,255,255,.5); background: rgba(255,255,255,.08); }
.node.done { color: var(--green); border-color: rgba(61,220,132,.6); background: rgba(61,220,132,.12); }
.node.waiting { animation: wait 1s ease-in-out infinite; }
@keyframes wait { 50% { border-color: rgba(239,163,74,.7); } }
.arrow { flex: none; width: 26px; height: 4px; border-radius: 2px; background: var(--line); position: relative; transition: background-color .35s; }
.arrow::after { content: ""; position: absolute; right: -2px; top: -5px; border: 7px solid transparent; border-right: 0; border-left-color: inherit; }
.arrow { border-left-color: rgba(255,255,255,.10); }
.arrow.lit { background: var(--amber); border-left-color: var(--amber); }
.arrow.done { background: var(--green); border-left-color: var(--green); }

/* ------------------------------------------------------------------ layout */
main {
  position: absolute; left: 44px; right: 44px; top: 164px; bottom: 56px;
  display: grid; grid-template-columns: 760px 1fr; gap: 40px;
}
section { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.sec-head { height: 84px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.sec-title { min-width: 0; overflow: hidden; }
.sec-title h2, .sec-title .sec-sub { overflow: hidden; text-overflow: ellipsis; }
.sec-head h2 { margin: 0; font-size: 33px; font-weight: 750; letter-spacing: -0.01em; white-space: nowrap; }
.sec-sub { margin-top: 2px; font-size: 21px; color: var(--muted); white-space: nowrap; }

.view-renter main, .view-partner main { grid-template-columns: 1fr; }
.view-renter #partner, .view-partner #renter { display: none; }

/* LED mirror */
.boxled { display: flex; align-items: center; gap: 12px; padding: 10px 18px 10px 12px; border-radius: 16px; background: #E8ECEE; color: #23323A; font-size: 20px; font-weight: 800; box-shadow: inset 0 -4px 0 rgba(0,0,0,.12); }
.led { display: inline-block; width: 26px; height: 26px; border-radius: 50%; background: #2B3438; box-shadow: inset 0 2px 4px rgba(0,0,0,.5); transition: none; }
.led.big { width: 96px; height: 96px; }

/* ------------------------------------------------------------------ renter: phone */
.renter-row { flex: 1; min-height: 0; display: flex; justify-content: center; gap: 90px; padding-bottom: 16px; }
.phone {
  position: relative; flex: none; width: 600px; height: 100%;
  border-radius: 60px; background: var(--phone); border: 3px solid rgba(255,255,255,.16);
  box-shadow: 0 30px 80px rgba(0,0,0,.45), inset 0 0 0 10px #071419;
  padding: 24px 44px 30px; display: flex; flex-direction: column; overflow: hidden;
}
.ph-status { display: flex; justify-content: space-between; align-items: center; font-size: 22px; font-weight: 700; color: var(--muted); padding: 0 8px; height: 30px; }
.ph-icons { display: flex; gap: 5px; align-items: flex-end; }
.ph-icons i { width: 6px; background: var(--muted); border-radius: 2px; }
.ph-icons i:nth-child(1) { height: 8px; } .ph-icons i:nth-child(2) { height: 12px; } .ph-icons i:nth-child(3) { height: 16px; }
.ph-icons b { width: 30px; height: 15px; border: 2px solid var(--muted); border-radius: 4px; margin-left: 8px; }

.ph-head { margin-top: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.ph-brand { display: flex; align-items: center; gap: 12px; font-size: 29px; font-weight: 750; }
.ph-logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--green), var(--blue)); }
.ph-sub { margin-top: 4px; font-size: 22px; color: var(--muted); }

.ph-set { margin-top: 10px; text-align: center; }
.ph-set-label { font-size: 23px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ph-set-val { font-size: 164px; font-weight: 800; line-height: 1.02; letter-spacing: -0.04em; color: var(--text); transition: color .6s; }
.ph-set-val .deg { font-size: 64px; font-weight: 700; color: var(--muted); vertical-align: 80px; margin-left: 6px; letter-spacing: 0; }
#setVal { display: inline-block; }
#setVal.tick { animation: tick .55s cubic-bezier(.2,.9,.3,1.2); }
@keyframes tick { 0% { transform: translateY(40px); opacity: .2; } 100% { transform: none; opacity: 1; } }
.phone[data-mode="event"] .ph-set-val { color: var(--amber); }

.pill { align-self: center; display: inline-flex; align-items: center; gap: 14px; margin-top: 4px; padding: 11px 28px; border-radius: 999px; font-size: 29px; font-weight: 750; background: rgba(77,163,255,.16); color: var(--blue); transition: background .5s, color .5s; }
.pill i { width: 16px; height: 16px; border-radius: 50%; background: currentColor; }
.phone[data-mode="event"] .pill { background: rgba(239,163,74,.18); color: var(--amber); }
.phone[data-mode="event"] .pill i { animation: blink 1.6s infinite; }
.phone[data-mode="over"] .pill { background: rgba(255,255,255,.14); color: var(--white); }
.ph-note { margin-top: 12px; text-align: center; font-size: 27px; font-weight: 600; min-height: 34px; }

.ph-earn { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.earn-col { text-align: center; }
.earn-label { font-size: 23px; font-weight: 700; color: var(--muted); }
.earn-val { font-size: 60px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
#earnEvent { color: var(--green); }
.earn-sub { font-size: 19px; color: var(--muted); }
.ph-illus { margin-top: 4px; text-align: center; font-size: 17px; color: var(--muted); opacity: .8; }

.ph-bottom { position: relative; margin-top: 14px; height: 104px; flex: none; }
.ov-btn {
  width: 100%; height: 100%; border: 0; border-radius: 28px; font-size: 38px; font-weight: 800;
  background: var(--white); color: #0A1A21; cursor: pointer; transition: opacity .4s, transform .12s;
  box-shadow: 0 10px 30px rgba(255,255,255,.18);
}
.ov-btn:active { transform: scale(.98); }
.ov-btn.dim { opacity: .28; box-shadow: none; cursor: default; }
.ov-btn.done { background: rgba(255,255,255,.12); color: var(--text); box-shadow: none; }

.reward {
  position: absolute; inset: 0; border-radius: 28px; display: flex; align-items: center; justify-content: center; gap: 18px; padding: 0 20px;
  background: linear-gradient(135deg, #1E9E5C, var(--green)); color: #04210F;
  opacity: 0; transform: translateY(30px) scale(.94); pointer-events: none;
  transition: opacity .35s, transform .5s cubic-bezier(.2,.9,.3,1.3);
}
.reward.show { opacity: 1; transform: none; box-shadow: 0 0 60px rgba(61,220,132,.45); }
.reward-amt { font-size: 56px; font-weight: 850; letter-spacing: -0.02em; }
.reward-txt { font-size: 26px; font-weight: 750; line-height: 1.15; white-space: nowrap; }
.reward-txt small { display: block; font-size: 19px; font-weight: 650; opacity: .8; }

.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; border-radius: 56px; }
.flash.go { animation: flash .6s ease-out; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }

.callout {
  position: absolute; left: 28px; right: 28px; top: 90px; display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 20px 20px; border-radius: 26px; background: #071419; border: 3px solid var(--white);
  font-size: 34px; font-weight: 800; color: var(--white); box-shadow: 0 0 50px rgba(255,255,255,.35); white-space: nowrap;
  opacity: 0; transform: scale(.85); pointer-events: none; transition: opacity .25s, transform .35s cubic-bezier(.2,.9,.3,1.4);
}
.callout.show { opacity: 1; transform: none; }
.callout-icon { width: 30px; height: 46px; border-radius: 8px; border: 4px solid var(--white); flex: none; }

/* ------------------------------------------------------------------ renter full screen: the box card */
.boxcard { display: none; flex: none; width: 600px; flex-direction: column; align-items: center; justify-content: center; gap: 22px; text-align: center; }
.view-renter .boxcard { display: flex; }
.boxcard-title { font-size: 34px; font-weight: 750; }
.bigbox { width: 440px; height: 270px; border-radius: 56px; background: linear-gradient(#F6F4F0, #D7D2C8); box-shadow: 0 30px 70px rgba(0,0,0,.45), inset 0 -8px 0 rgba(0,0,0,.08); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 30px; }
.bigbox-name { font-size: 26px; font-weight: 800; color: #6F6A60; letter-spacing: .04em; }
.boxcard-state { font-size: 44px; font-weight: 800; }
.boxcard-sub { font-size: 28px; color: var(--muted); max-width: 560px; }
.boxcard-conn { font-size: 22px; color: var(--muted); }

/* ------------------------------------------------------------------ partner */
.dispatch {
  flex: none; display: flex; align-items: center; gap: 14px; height: 64px; padding: 0 26px 0 16px; border-radius: 18px;
  border: 0; background: var(--amber); color: #2A1A05; font-size: 25px; font-weight: 850; cursor: pointer;
  box-shadow: 0 10px 30px rgba(239,163,74,.25); transition: opacity .3s, transform .12s;
}
.dispatch kbd { background: rgba(0,0,0,.18); color: #2A1A05; font-size: 18px; padding: 3px 9px; }
.dispatch:active { transform: scale(.98); }
.dispatch.sent { background: rgba(239,163,74,.16); color: var(--amber); box-shadow: none; cursor: default; }
.dispatch.sent kbd { display: none; }

.kpis { flex: none; display: grid; grid-template-columns: 1.25fr 1.15fr 1fr; gap: 24px; height: 280px; }
.kpi { position: relative; background: var(--navy); border-radius: 30px; padding: 22px 28px 20px; display: flex; flex-direction: column; overflow: hidden; }
.kpi-label { font-size: 27px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.kpi-val { margin-top: 4px; font-size: 104px; font-weight: 800; line-height: 1; letter-spacing: -0.035em; white-space: nowrap; overflow: hidden; }
.kpi-val small { font-size: 38px; font-weight: 700; color: var(--muted); margin-left: 8px; letter-spacing: 0; }
.kpi-sub { margin-top: auto; font-size: 22px; color: var(--muted); font-weight: 600; white-space: nowrap; }
#kpiKw .kpi-val { color: var(--amber); }
#kwRefLabel::before { content: ""; display: inline-block; width: 4px; height: 22px; margin-right: 10px; vertical-align: -3px; border-radius: 2px; background: var(--white); }
.bar { position: relative; margin-top: 18px; height: 18px; border-radius: 9px; background: rgba(255,255,255,.12); }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 9px; background: var(--amber); }
.bar .ref { position: absolute; top: -10px; bottom: -10px; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--white); }
.target { margin-top: 10px; font-size: 28px; font-weight: 850; white-space: nowrap; }
.target.ok { color: var(--green); }
.target.bad { color: var(--red); }

.dots-card { flex: 1; min-height: 0; margin: 20px 0 16px; background: var(--navy); border-radius: 30px; padding: 22px 30px 18px; display: flex; flex-direction: column; }
.dots-head { display: flex; justify-content: space-between; align-items: center; }
.legend { display: flex; gap: 34px; font-size: 26px; font-weight: 700; }
.legend span { display: flex; align-items: center; gap: 12px; }
.d { width: 24px; height: 24px; border-radius: 50%; display: inline-block; }
.d.normal { background: var(--blue); } .d.easing { background: var(--amber); } .d.over { background: var(--grey); }
.dots-note { font-size: 22px; color: var(--muted); }

.dots { flex: 1; display: grid; gap: 12px 0; align-content: center; justify-items: center; padding-top: 50px; }
.dot { position: relative; width: 30px; height: 30px; border-radius: 50%; background: var(--blue); transition: background-color .7s, transform .3s; }
.dot.easing { background: var(--amber); }
.dot.over { background: var(--grey); transform: scale(.82); }
.dot.pop { animation: pop .7s ease-out; }
@keyframes pop { 0% { transform: scale(1.9); background: #fff; } 100% { transform: scale(.82); } }
.dot.apt { z-index: 2; box-shadow: 0 0 0 5px var(--navy), 0 0 0 9px var(--white); }
.dot.apt.over { transform: none; }
.dot.apt.pop { animation: popApt .7s ease-out; }
@keyframes popApt { 0% { transform: scale(1.9); background: #fff; } 100% { transform: none; } }
.dot.apt::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 4px solid var(--white); animation: ring 2s ease-out infinite; }
@keyframes ring { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(2.3); opacity: 0; } }
.apt-tag {
  position: absolute; bottom: 50px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 23px; font-weight: 800; color: #0A1A21; background: var(--white); padding: 5px 14px; border-radius: 10px;
}
.apt-tag::after { content: ""; position: absolute; left: 50%; bottom: -8px; margin-left: -8px; border: 8px solid transparent; border-bottom: 0; border-top-color: var(--white); }
.dots-caption { flex: none; margin-top: 8px; text-align: center; font-size: 27px; font-weight: 650; min-height: 36px; }
.dots-caption.done { color: var(--green); }

/* partner full screen: bigger everything */
.view-partner .kpis { height: 300px; }
.view-partner .kpi-val { font-size: 132px; }
.view-partner .kpi-val small { font-size: 46px; }
.view-partner .dot { width: 38px; height: 38px; }
.view-partner .dots { gap: 14px 0; padding-top: 54px; }
.view-partner .apt-tag { bottom: 58px; }

/* ------------------------------------------------------------------ footer, toast, help */
#footer { position: absolute; left: 0; right: 0; bottom: 0; height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 44px; }
#legend { display: flex; align-items: center; gap: 18px; font-size: 17px; color: var(--muted); white-space: nowrap; }
#legend b { color: var(--text); }
body.hide-legend #legend { visibility: hidden; }
#autoChip { font-size: 15px; font-weight: 800; letter-spacing: .12em; padding: 4px 10px; border-radius: 7px; background: rgba(239,163,74,.2); color: var(--amber); display: none; }
#autoChip.on { display: inline-block; }
#foot { font-size: 19px; color: var(--muted); }
#keys {
  position: absolute; left: 24px; right: 24px; bottom: 6px; height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 10px 0 18px; border-radius: 14px; background: #0F2A34; border: 1px solid var(--line);
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
body.show-keys #keys { opacity: 1; pointer-events: auto; }
.next { font-size: 19px; color: var(--muted); white-space: nowrap; }
.next b { color: var(--text); }
.btns { display: flex; gap: 6px; }
.btns button { display: flex; align-items: center; gap: 7px; font-size: 15px; font-weight: 650; color: var(--text); background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 9px; padding: 6px 9px; cursor: pointer; }
.btns button:hover { background: rgba(255,255,255,.14); }
.btns button.on { background: var(--amber); color: #2A1A05; }
kbd { font-family: var(--font); font-size: 14px; font-weight: 800; min-width: 22px; padding: 1px 6px; border-radius: 5px; background: rgba(255,255,255,.16); color: var(--text); text-align: center; }

#toast {
  position: absolute; left: 50%; bottom: 84px; transform: translate(-50%, 20px); padding: 16px 30px; border-radius: 18px;
  background: #F2F7F9; color: #0A1A21; font-size: 28px; font-weight: 750; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .3s; box-shadow: 0 20px 50px rgba(0,0,0,.4); white-space: nowrap; z-index: 9;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#help { position: absolute; inset: 0; background: rgba(3, 10, 13, .82); display: grid; place-items: center; z-index: 10; }
#help.off, #fatal.off { display: none; }
.help-card { width: 1100px; background: #102C36; border: 1px solid var(--line); border-radius: 30px; padding: 40px 50px; }
.help-card h3 { margin: 0 0 24px; font-size: 40px; }
.help-grid { display: grid; grid-template-columns: 190px 1fr; gap: 14px 24px; font-size: 26px; align-items: center; }
.help-grid kbd { font-size: 22px; padding: 4px 12px; }
.help-foot { margin: 26px 0 0; font-size: 24px; color: var(--muted); }
.help-foot b { color: var(--text); }

#fatal { position: absolute; inset: 0; z-index: 20; background: var(--bg); display: grid; place-items: center; padding: 80px; font-size: 34px; font-weight: 700; text-align: center; color: var(--amber); }

@media (prefers-reduced-motion: reduce) {
  .dot.apt::after, #badge i, .node.waiting, .phone[data-mode="event"] .pill i { animation: none; }
}

/* the big box replaces the small LED mirror in the renter view */
.view-renter .boxled { display: none; }
