:root {
  --idle:#16a34a; --busy:#e0453f; --offline:#9aa1ad; --hiro:#E88005; --navy:#272a6b;
  --bg:#eef0f5; --card:#ffffff; --fg:#1d2433; --muted:#6b7280; --line:#e4e7ee;
}
* { box-sizing: border-box; }
body { margin:0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background:var(--bg); color:var(--fg); -webkit-font-smoothing:antialiased; }

/* ---------- Header ---------- */
#app-header { padding:9px 14px; display:flex; justify-content:space-between; align-items:center; gap:10px; border-bottom:1px solid var(--line); position:sticky; top:0; z-index:10; background:rgba(255,255,255,.92); backdrop-filter:saturate(1.2) blur(8px); }
#app-header .brand { display:flex; align-items:center; gap:10px; min-width:0; }
#app-header .brand-logo { width:auto; display:block; flex:none; }
#app-header .brand-logo.hiro { height:26px; }
#app-header .brand-logo.fem { height:57px; }
#app-header .brand-div { width:1px; height:42px; background:var(--line); flex:none; }
#app-header .used { font-size:12px; font-weight:600; color:var(--muted); background:#fff; border:1px solid var(--line); padding:4px 11px; border-radius:999px; white-space:nowrap; flex:none; }
#app-header .used b { color:var(--hiro); font-weight:800; }

/* ---------- Device-grouped sections ---------- */
#machine-list { display:flex; flex-direction:column; padding-bottom:28px; }
.m-group { padding-bottom:4px; }
.group-head { display:flex; align-items:center; gap:8px; padding:16px 16px 8px; position:sticky; top:76px; z-index:5; background:linear-gradient(var(--bg) 80%, transparent); }
.group-dot { width:9px; height:9px; border-radius:50%; flex:none; }
.group-dot.washer{ background:#3b94e0; } .group-dot.dryer{ background:#f0922f; } .group-dot.other{ background:#9aa1ad; }
.group-title { font-size:12px; font-weight:800; text-transform:uppercase; letter-spacing:.09em; color:#7a8193; }
.group-count { font-size:11px; font-weight:700; color:#8a90a0; background:#fff; border:1px solid var(--line); padding:1px 9px; border-radius:999px; }
.group-count.has { color:#157f3c; border-color:rgba(22,163,74,.35); background:#effaf2; }
.grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(148px,1fr)); gap:12px; padding:0 14px; }

/* ---------- Machine card ---------- */
.card { background:var(--card); border:1px solid var(--line); border-radius:16px; padding:12px 12px 14px; display:flex; flex-direction:column; gap:6px; min-height:150px; box-shadow:0 1px 2px rgba(20,30,60,.05); }
.card.idle { cursor:pointer; transition:transform .14s ease, border-color .14s ease, box-shadow .14s ease; }
.card.idle:hover { border-color:rgba(22,163,74,.55); transform:translateY(-2px); box-shadow:0 12px 24px -14px rgba(20,40,80,.4); }
.card.idle:active { transform:scale(.985); }
.card.busy { border-color:rgba(224,69,63,.4); box-shadow:0 6px 18px -12px rgba(224,69,63,.5); }
.card.offline { opacity:.55; }
.card.loading { opacity:.92; }
.card-head { display:flex; align-items:center; justify-content:space-between; min-height:22px; }
.card-foot .name { font-weight:800; font-size:15px; line-height:1.1; color:var(--navy); }
.card-foot .type { font-size:11px; color:var(--muted); margin-top:2px; }
.pill { font-size:11px; font-weight:700; letter-spacing:.02em; padding:3px 10px; border-radius:999px; color:#fff; }
.pill.idle{ background:var(--idle); } .pill.busy{ background:var(--busy); } .pill.offline{ background:var(--offline); }
.pill.loading{ background:#cbd1dc; color:#5a6172; animation:pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.5;} }
.count { font-variant-numeric:tabular-nums; font-size:14px; font-weight:800; color:var(--busy); }

/* ---------- Front-loader icon ---------- */
.m-icon-wrap { display:flex; justify-content:center; padding:4px 0 2px; }
.m-icon { width:64px; height:64px; color:#2b3344; }
.card.offline .m-icon { color:#aeb4c0; }
.card.loading .m-icon { color:#b7bdc9; }
.m-body, .m-door, .m-panel, .m-pad { stroke:currentColor; }
.m-body { stroke-width:2; }
.m-panel { stroke-width:2; stroke-linecap:round; }
.m-door { stroke-width:2.5; }
.m-glass { fill:rgba(39,42,107,.05); }
.m-knob { fill:var(--hiro); }
.card.offline .m-knob { fill:#aeb4c0; }
.m-pad { stroke-width:2.6; stroke-linecap:round; }
.m-water { stroke:#3b94e0; stroke-width:2.4; stroke-linecap:round; }
.m-heat circle { fill:#f0922f; }
@keyframes drum-spin { to { transform:rotate(360deg); } }
.m-icon .drum { transform-box:view-box; transform-origin:32px 38px; }
.card.busy .m-icon .drum { animation:drum-spin 1.4s linear infinite; }
@media (prefers-reduced-motion: reduce) { .card.busy .m-icon .drum, .splash-drum .sd-drum { animation:none !important; } }

/* ---------- Modals (options / result) ---------- */
.screen.modal { position:fixed; inset:0; background:rgba(29,36,51,.42); backdrop-filter:blur(3px); display:none; align-items:center; justify-content:center; z-index:20; }
.screen.modal[aria-hidden="false"] { display:flex; }
#screen-options { align-items:stretch; justify-content:stretch; background:var(--bg); backdrop-filter:none; padding:0; }
.btn { background:var(--hiro); color:#fff; font-weight:800; border:0; border-radius:14px; padding:15px 22px; width:100%; font-size:16px; box-shadow:0 10px 22px -8px rgba(232,128,5,.65); cursor:pointer; }
.btn[disabled] { background:#cdd2db; color:#fff; box-shadow:none; cursor:default; }

/* ---------- Full-page options ---------- */
.opt-page { width:100%; max-width:560px; margin:0 auto; height:100%; background:var(--bg); display:flex; flex-direction:column; overflow:hidden; animation:page-in .3s cubic-bezier(.2,.8,.3,1); }
@keyframes page-in { from{ transform:translateX(24px); opacity:0;} to{ transform:translateX(0); opacity:1;} }
@keyframes sheet-up { from{ transform:translateY(30px); opacity:.4;} to{ transform:translateY(0); opacity:1;} }

.opt-top { display:flex; align-items:center; gap:12px; padding:14px 16px calc(14px + env(safe-area-inset-top)); position:absolute; top:0; left:0; right:0; z-index:2; }
.opt-back { width:40px; height:40px; border-radius:50%; border:1px solid var(--line); background:rgba(255,255,255,.85); font-size:20px; color:var(--fg); flex:none; cursor:pointer; line-height:1; backdrop-filter:blur(4px); }
.opt-back:active { transform:scale(.93); }
.opt-id { display:flex; flex-direction:column; min-width:0; line-height:1.15; }
.opt-name { font-weight:800; color:var(--navy); font-size:17px; }
.opt-type { font-size:12px; color:var(--muted); }

/* Hero */
.opt-hero { position:relative; height:min(42vh,300px); flex:none; display:flex; align-items:center; justify-content:center;
  --glow:var(--glow-col, #3a8dde); }
.opt-glow { position:absolute; width:300px; height:300px; border-radius:50%; background:radial-gradient(circle, var(--glow) 0%, transparent 68%); opacity:calc(.22 + var(--warmth)*.4); filter:blur(8px); transition:opacity .4s ease, background .4s ease; }
.opt-drum { width:190px; height:190px; position:relative; z-index:1; }
.od-door { stroke:var(--glow); stroke-width:2.4; fill:rgba(255,255,255,.55); transition:stroke .4s ease; }
.od-glass { stroke:color-mix(in srgb, var(--glow), #1d2433 30%); stroke-width:1.6; fill:color-mix(in srgb, var(--glow) 22%, #fff); transition:all .4s ease; }
.od-pad { stroke:color-mix(in srgb, var(--glow), #1d2433 25%); stroke-width:2.4; stroke-linecap:round; }
.od-drum { transform-box:view-box; transform-origin:32px 32px; animation:drum-spin calc(6s - var(--warmth)*3.5s) linear infinite; }
/* Bubbles when add-ons selected */
.opt-bubbles { position:absolute; inset:0; display:none; pointer-events:none; z-index:2; }
.opt-hero[data-addons="1"] .opt-bubbles { display:block; }
.opt-bubbles i { position:absolute; bottom:30%; width:13px; height:13px; border-radius:50%;
  background:radial-gradient(circle at 33% 28%, #ffffff 0%, #eaf1fb 55%, #cdddf2 100%);
  box-shadow:0 0 0 1.3px rgba(90,120,170,.45), 0 3px 8px rgba(20,30,60,.22), inset -2px -2px 3px rgba(120,150,200,.35);
  animation:bub 2.4s ease-in infinite; }
.opt-bubbles i:nth-child(1){ left:42%; width:13px; height:13px; animation-delay:0s; }
.opt-bubbles i:nth-child(2){ left:54%; width:10px; height:10px; animation-delay:.7s; }
.opt-bubbles i:nth-child(3){ left:48%; width:16px; height:16px; animation-delay:1.5s; }
@keyframes bub { 0%{ transform:translateY(0) scale(.5); opacity:0;} 20%{ opacity:.95;} 80%{ opacity:.85;} 100%{ transform:translateY(-78px) scale(1); opacity:0;} }

/* Body */
.opt-body { padding:4px 18px 18px; overflow-y:auto; flex:1; }
.opt-section { margin-top:14px; }
.opt-h { font-size:12px; font-weight:800; text-transform:uppercase; letter-spacing:.08em; color:#8a90a0; margin:6px 2px 10px; }
.tiles { display:flex; gap:10px; flex-wrap:wrap; }
.tile { flex:1; position:relative; display:flex; flex-direction:column; align-items:center; gap:4px; padding:16px 8px; background:#fff; border:2px solid var(--line); border-radius:18px; cursor:pointer; transition:border-color .15s ease, transform .1s ease; text-align:center; }
.tile input { position:absolute; opacity:0; pointer-events:none; }
.t-ico { width:30px; height:30px; }
.t-tube { stroke:#b3b9c6; stroke-width:1.6; }
.t-merc-line { stroke:var(--mc); stroke-width:3.4; stroke-linecap:round; transition:stroke .25s ease; }
.t-merc-fill { fill:var(--mc); transition:fill .25s ease; }
.tile-name { font-weight:800; color:var(--navy); font-size:14px; }
.tile-price { font-size:12px; color:var(--muted); font-variant-numeric:tabular-nums; }
.tile:active { transform:scale(.97); }
.tile:has(input:checked) { border-color:var(--mc); box-shadow:0 6px 18px -10px rgba(20,30,60,.5); }

/* Footer */
.opt-footer { padding:12px 18px calc(14px + env(safe-area-inset-bottom)); border-top:1px solid var(--line); background:#fff; flex:none; }
.opt-breakdown { display:flex; flex-direction:column; gap:3px; margin-bottom:10px; }
.opt-breakdown:empty { display:none; }
.bd-line { display:flex; justify-content:space-between; font-size:13px; color:var(--muted); font-variant-numeric:tabular-nums; animation:bd-in .2s ease; }
.bd-line span:last-child { color:var(--fg); font-weight:600; }
@keyframes bd-in { from{ opacity:0; transform:translateY(-3px);} to{ opacity:1; transform:translateY(0);} }
.opt-foot-row { display:flex; align-items:center; gap:14px; }
.opt-total { flex:1; display:flex; flex-direction:column; line-height:1.1; }
.opt-total > span { font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.06em; }
.opt-total strong { font-size:22px; color:var(--navy); font-variant-numeric:tabular-nums; }
#subtotal.roll { animation:roll .3s ease; display:inline-block; }
@keyframes roll { 0%{ transform:translateY(6px); opacity:.3;} 100%{ transform:translateY(0); opacity:1;} }
.opt-foot-row .btn { width:auto; flex:none; min-width:160px; }

@media (prefers-reduced-motion: reduce) {
  .od-drum, .opt-bubbles i { animation:none !important; }
  .opt-page { animation:none !important; }
  .bd-line, #subtotal.roll { animation:none !important; }
}

.opt { position:relative; display:flex; align-items:center; gap:12px; padding:15px 16px; border:1.5px solid var(--line); border-radius:15px; margin:8px 0; background:#fff; cursor:pointer; transition:border-color .12s ease, background .12s ease, box-shadow .12s ease; }
.opt input { position:absolute; opacity:0; pointer-events:none; }
.opt-text { flex:1; font-weight:700; color:var(--navy); }
.opt-price { font-weight:700; color:var(--fg); font-variant-numeric:tabular-nums; }
.opt-check { width:22px; height:22px; border-radius:50%; border:2px solid #d4d8e1; flex:none; position:relative; transition:all .12s ease; }
.opt:has(input:checked) { border-color:var(--hiro); background:#fff7ee; box-shadow:0 0 0 1px var(--hiro) inset; }
.opt:has(input:checked) .opt-check { border-color:var(--hiro); background:var(--hiro); }
.opt:has(input:checked) .opt-check::after { content:''; position:absolute; left:6px; top:2.5px; width:5px; height:10px; border:solid #fff; border-width:0 2.5px 2.5px 0; transform:rotate(45deg); }
.opt:active { transform:scale(.992); }
.stepper { display:flex; align-items:center; justify-content:space-between; gap:16px; background:#f5f6fa; border:1px solid var(--line); border-radius:18px; padding:14px 18px; }
.step-btn { width:48px; height:48px; border-radius:50%; border:1px solid var(--line); background:#fff; font-size:26px; line-height:1; color:var(--hiro); font-weight:700; cursor:pointer; box-shadow:0 1px 2px rgba(20,30,60,.08); }
.step-btn:active { transform:scale(.93); }
.step-val { text-align:center; }
.step-val b { display:block; font-size:34px; font-weight:800; color:var(--navy); font-variant-numeric:tabular-nums; line-height:1; }
.step-val span { font-size:12px; color:var(--muted); }

/* Result screen */
.result-card { width:100%; max-width:380px; margin:0 18px; background:#fff; border-radius:24px; padding:36px 26px 26px; text-align:center; box-shadow:0 24px 60px -20px rgba(20,30,60,.5); animation:sheet-up .3s cubic-bezier(.2,.8,.3,1); }
.result-check svg { width:76px; height:76px; }
.result-check .rc-ring { fill:none; stroke:var(--idle); stroke-width:3; opacity:.25; }
.result-check .rc-tick { fill:none; stroke:var(--idle); stroke-width:4; stroke-linecap:round; stroke-linejoin:round; stroke-dasharray:40; stroke-dashoffset:40; animation:tick .45s ease forwards .15s; }
@keyframes tick { to { stroke-dashoffset:0; } }
.result-title { margin:14px 0 4px; color:var(--navy); font-size:22px; }
.result-sub { margin:0; color:var(--muted); font-weight:600; }
.result-count { margin:14px 0 22px; font-size:13px; color:#9aa1ad; }
.result-card .btn { width:100%; }
.state { text-align:center; color:var(--muted); padding:48px 12px; }
.state.error { color:#c0392b; }
.toast { position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:#1d2433; color:#fff; padding:11px 18px; border-radius:12px; font-size:14px; opacity:0; transition:opacity .2s; z-index:50; box-shadow:0 10px 30px -10px rgba(0,0,0,.5); }
.toast.show { opacity:1; }

/* ---------- Welcome splash ---------- */
#splash { position:fixed; inset:0; z-index:100; background:#fff; display:flex; align-items:center; justify-content:center; overflow:hidden; transition:opacity .55s ease, transform .55s ease; }
#splash.hide { opacity:0; transform:scale(1.04); pointer-events:none; }
.splash-glow { position:absolute; inset:0; background:
  radial-gradient(60% 40% at 50% 12%, rgba(232,128,5,.14), transparent 70%),
  radial-gradient(55% 35% at 50% 96%, rgba(39,42,107,.10), transparent 70%); }
.splash-inner { position:relative; text-align:center; padding:24px; display:flex; flex-direction:column; align-items:center; }
.splash-eyebrow { font-size:12px; font-weight:800; letter-spacing:.32em; color:#9aa1ad; opacity:0; animation:rise .6s ease forwards .15s; }
.splash-hiro { width:148px; max-width:55vw; margin:14px 0 4px; opacity:0; transform:scale(.78); animation:pop .7s cubic-bezier(.18,1.5,.4,1) forwards .32s; }
.splash-at { display:flex; align-items:center; gap:10px; font-size:12px; font-weight:600; color:#aab; letter-spacing:.04em; margin:8px 0 12px; opacity:0; animation:rise .5s ease forwards .62s; }
.splash-at span { width:26px; height:1px; background:var(--line); display:block; }
.splash-fem { width:230px; max-width:74vw; opacity:0; transform:translateY(12px); animation:rise .6s ease forwards .76s; }
.splash-loader { margin-top:34px; opacity:0; animation:rise .5s ease forwards 1.05s; }
.splash-drum { width:46px; height:46px; color:var(--hiro); }
.splash-drum .sd-door { stroke:var(--hiro); stroke-width:2.4; fill:none; }
.splash-drum .sd-glass { fill:rgba(232,128,5,.07); }
.splash-drum .sd-pad { stroke:var(--hiro); stroke-width:2.8; stroke-linecap:round; }
.splash-drum .sd-drum { transform-box:view-box; transform-origin:32px 32px; animation:drum-spin 1.15s linear infinite; }
.splash-status { margin-top:12px; font-size:13px; color:#9aa1ad; font-weight:600; }
@keyframes rise { from{ opacity:0; transform:translateY(12px);} to{ opacity:1; transform:translateY(0);} }
@keyframes pop { from{ opacity:0; transform:scale(.78);} to{ opacity:1; transform:scale(1);} }

/* ---------- Activation screen ---------- */
.act-screen { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:18px; width:100%; max-width:380px; margin:0 18px; padding:34px 26px 30px; background:#fff; border-radius:24px; box-shadow:0 24px 60px -20px rgba(20,30,60,.5); animation:pop .3s ease; }
.act-hero { position:relative; width:200px; height:200px; display:flex; align-items:center; justify-content:center; --warmth:.5; --glow:#E88005; }
.act-glow { position:absolute; width:230px; height:230px; border-radius:50%; background:radial-gradient(circle, var(--glow) 0%, transparent 68%); opacity:.4; filter:blur(8px); animation:act-pulse 1.3s ease-in-out infinite; }
@keyframes act-pulse { 0%,100%{ opacity:.26; transform:scale(.95);} 50%{ opacity:.55; transform:scale(1.07);} }
.act-drum { width:150px; height:150px; position:relative; z-index:1; }
.act-hero .od-drum { animation:drum-spin .7s linear infinite; }
.act-title { color:var(--navy); font-size:20px; font-weight:800; margin:0; text-align:center; }
.act-bar { width:180px; height:5px; border-radius:3px; background:#e7eaf1; overflow:hidden; position:relative; }
.act-bar span { position:absolute; left:0; width:40%; height:100%; border-radius:3px; background:var(--hiro); transform:translateX(-110%); animation:act-bar 1.1s ease-in-out infinite; }
@keyframes act-bar { 0%{ transform:translateX(-110%);} 100%{ transform:translateX(360%);} }

/* Failed state */
.result-x svg { width:76px; height:76px; }
.result-x .rx-ring { fill:none; stroke:#e85842; stroke-width:3; opacity:.25; }
.result-x .rx-a, .result-x .rx-b { fill:none; stroke:#e85842; stroke-width:4; stroke-linecap:round; stroke-dasharray:24; stroke-dashoffset:24; }
.result-x .rx-a { animation:tick .3s ease forwards .12s; }
.result-x .rx-b { animation:tick .3s ease forwards .30s; }
.btn-ghost { background:#fff; color:var(--navy); border:1px solid var(--line); box-shadow:none; margin-top:10px; }
.btn-ghost:active { transform:scale(.98); }

@media (prefers-reduced-motion: reduce) {
  .act-glow, .act-hero .od-drum, .act-bar span { animation:none !important; }
  .result-x .rx-a, .result-x .rx-b, .result-check .rc-tick { animation:none !important; stroke-dashoffset:0 !important; }
}
