/* Masaga Warehouse — Merlot / Cream with the warehouse cyan accent. */
:root {
  color-scheme: dark;
  --bg: #140307; --s1: #1E050C; --s2: #2A0913; --s3: #36101D; --line: rgba(244, 231, 211, .12);
  --fg: #F4E7D3; --fg2: rgba(244, 231, 211, .7); --fg3: rgba(244, 231, 211, .45);
  --app: #5EDCEB; --app2: #1BA5B8; --coral: #FF3366; --ok: #34D399;
  --btn: #F4E7D3; --btn-fg: #140307;
  --display: "Space Grotesk", system-ui, sans-serif; --sans: "Plus Jakarta Sans", system-ui, sans-serif; --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { color-scheme: light;
  --bg: #FFFDF9; --s1: #FFFFFF; --s2: #F8EFE3; --s3: #F4E7D3; --line: rgba(115, 19, 43, .14);
  --fg: #24060E; --fg2: rgba(36, 6, 14, .72); --fg3: rgba(36, 6, 14, .5); --app: #0E8FA1; --app2: #0B6E7C; --btn: #24060E; --btn-fg: #FFFDF9; } }
:root[data-theme="light"] { color-scheme: light;
  --bg: #FFFDF9; --s1: #FFFFFF; --s2: #F8EFE3; --s3: #F4E7D3; --line: rgba(115, 19, 43, .14);
  --fg: #24060E; --fg2: rgba(36, 6, 14, .72); --fg3: rgba(36, 6, 14, .5); --app: #0E8FA1; --app2: #0B6E7C; --btn: #24060E; --btn-fg: #FFFDF9; }

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { background: var(--bg); color: var(--fg); font: 400 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
:focus-visible { outline: 2px solid var(--app); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--fg3); font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px; font-weight: 600; font-size: 14px; background: var(--s2); box-shadow: inset 0 0 0 1px var(--line); white-space: nowrap; transition: transform .12s, background .2s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--app); color: #062A30; box-shadow: 0 6px 0 var(--app2); }
.btn.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--app2); }
.btn.big { height: 56px; font-size: 17px; border-radius: 16px; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--fg2); }
.btn.ghost:hover { color: var(--fg); background: var(--s2); }
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; box-shadow: inset 0 0 0 1.5px var(--line); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--fg); stroke-width: 1.8; stroke-linecap: round; grid-area: 1 / 1; transition: opacity .3s, transform .4s var(--ease); }
.icon-btn .i-moon { opacity: 0; transform: scale(.6); }
:root[data-theme="light"] .icon-btn .i-sun { opacity: 0; transform: scale(.6); }
:root[data-theme="light"] .icon-btn .i-moon { opacity: 1; transform: none; }
@media (prefers-color-scheme: light) { :root:not([data-theme]) .icon-btn .i-sun { opacity: 0; } :root:not([data-theme]) .icon-btn .i-moon { opacity: 1; transform: none; } }

.brand { display: flex; align-items: center; gap: 12px; }
.brand img { border-radius: 11px; }
.brand b { font: 700 18px/1 var(--display); letter-spacing: -.01em; }
.brand span { display: grid; gap: 4px; }
.brand small { color: var(--fg3); font-size: 13px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(60% 50% at 50% 0%, rgba(94, 220, 235, .12), transparent 70%); }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 18px; padding: 28px; border-radius: 26px; background: var(--s1); box-shadow: inset 0 0 0 1px var(--line), 0 30px 60px -30px rgba(0, 0, 0, .6); }
.login-card .brand b { font-size: 21px; }
.fld { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--fg2); }
.fld input, .fld select { height: 52px; padding: 0 16px; border-radius: 14px; border: 0; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); font-size: 17px; color: var(--fg); }
.fld input:focus, .fld select:focus { outline: none; box-shadow: inset 0 0 0 2px var(--app); }
.err { min-height: 20px; color: #FF7B9A; font-size: 14px; }

/* ---------- app ---------- */
.app { padding: 14px clamp(12px, 2.4vw, 28px) 40px; }
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.grow { flex: 1; }
.sync { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 99px; background: rgba(52, 211, 153, .12); color: var(--ok); font-size: 12.5px; font-weight: 600; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; }
.sync.busy { background: rgba(94, 220, 235, .12); color: var(--app); }
.sync.busy i { animation: pulse 1s infinite; }
.sync.off { background: rgba(255, 51, 102, .12); color: var(--coral); }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } }
.hint { color: var(--fg3); font-size: 13.5px; margin: 2px 2px 16px; max-width: 80ch; }

.floor { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 3fr) minmax(200px, 1fr); gap: 16px; align-items: start; }
.lane, .rack { background: var(--s1); border-radius: 22px; padding: 16px; box-shadow: inset 0 0 0 1px var(--line); min-width: 0; }
.lane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.lane-head h2 { font: 700 17px/1.1 var(--display); }
.cards { display: grid; gap: 10px; }
.empty { color: var(--fg3); font-size: 13.5px; padding: 14px; border-radius: 14px; border: 1.5px dashed var(--line); text-align: center; }

/* draggable delivery card */
.gr { position: relative; display: grid; gap: 4px; padding: 14px 16px; border-radius: 16px; background: linear-gradient(160deg, color-mix(in srgb, var(--c, var(--app)) 26%, var(--s2)), var(--s2)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c, var(--app)) 55%, transparent), 0 6px 0 rgba(0, 0, 0, .25); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; transition: transform .15s, opacity .2s; }
.gr b { font: 700 16px/1.15 var(--display); }
.gr .qty { font: 700 24px/1 var(--display); }
.gr small { color: var(--fg2); font-size: 12.5px; }
.gr.picked { outline: 3px solid var(--app); outline-offset: 3px; transform: translateY(-3px) rotate(-1.5deg); }
.gr.dragging-src { opacity: .35; }

/* racks */
.zone { margin-bottom: 16px; }
.zone h3 { font: 600 13px/1 var(--sans); color: var(--fg3); margin: 0 4px 10px; }
.bins { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.bin, .chip { min-width: 0; }
.bin { position: relative; min-height: 132px; display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 18px; background: linear-gradient(180deg, var(--s2), color-mix(in srgb, var(--s2) 70%, var(--bg))); box-shadow: inset 0 -7px 0 rgba(0, 0, 0, .22), inset 0 0 0 1px var(--line); transition: box-shadow .25s, transform .2s, background .3s; }
.bin-id { font: 500 12px/1 var(--mono); color: var(--fg3); display: flex; justify-content: space-between; }
.bin.target { box-shadow: inset 0 -7px 0 rgba(0, 0, 0, .22), inset 0 0 0 2px color-mix(in srgb, var(--app) 60%, transparent); animation: breathe 1.2s ease-in-out infinite; }
.bin.over { background: color-mix(in srgb, var(--app) 18%, var(--s2)); box-shadow: inset 0 0 0 3px var(--app), 0 0 30px color-mix(in srgb, var(--app) 45%, transparent); transform: scale(1.03); animation: none; }
@keyframes breathe { 50% { transform: translateY(-2px); } }
.chip { position: relative; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: color-mix(in srgb, var(--c) 20%, var(--s1)); box-shadow: inset 3px 0 0 var(--c); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.chip span { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip b { position: relative; font: 700 20px/1 var(--display); }
.chip.picked { outline: 3px solid var(--app); outline-offset: 2px; }
.chip.dragging-src { opacity: .35; }
.bin .free { margin-top: auto; color: var(--fg3); font-size: 12px; }

/* out lane */
.out-lane.drop { position: sticky; top: 12px; }
.out-hole { display: grid; place-items: center; gap: 8px; min-height: 150px; margin-bottom: 12px; border-radius: 18px; border: 2px dashed color-mix(in srgb, var(--coral) 45%, transparent); color: var(--fg2); font-size: 13.5px; text-align: center; padding: 14px; transition: background .2s, transform .2s, border-color .2s; }
.out-hole svg { width: 34px; height: 34px; fill: none; stroke: var(--coral); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.out-lane.target .out-hole { animation: breathe 1.2s ease-in-out infinite; border-color: var(--coral); }
.out-lane.over .out-hole { background: rgba(255, 51, 102, .14); transform: scale(1.03); }
.out-card { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--s2); font-size: 13px; animation: slideIn .5s var(--ease); }
.out-card b { font: 700 15px/1.2 var(--display); }
.out-card small { color: var(--fg3); }
@keyframes slideIn { from { opacity: 0; transform: translateX(30%); } }

/* drag ghost + effects */
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 70; pointer-events: none; transform-origin: 30% 30%; box-shadow: 0 24px 40px -16px rgba(0, 0, 0, .7) !important; }
.drag-ghost.fly { transition: transform .45s cubic-bezier(.6, 0, .2, 1), opacity .45s; }
.streak { position: fixed; z-index: 69; height: 10px; border-radius: 99px; pointer-events: none; transform-origin: left center; background: linear-gradient(90deg, transparent, var(--app)); filter: blur(2px); animation: streak .5s ease-out forwards; }
@keyframes streak { 0% { opacity: .9; } 100% { opacity: 0; } }
.pop { animation: popIn .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes popIn { 0% { transform: scale(.4); } 100% { transform: none; } }
.glow { animation: glow 1s ease-out; }
@keyframes glow { 0% { box-shadow: inset 0 0 0 3px var(--app), 0 0 40px var(--app); } }
.half { position: absolute; left: 0; top: 0; pointer-events: none; color: var(--coral); }
.half.t { clip-path: polygon(0 0, 100% 0, 100% 38%, 0 62%); animation: cutT .9s cubic-bezier(.2, .7, .3, 1) forwards; }
.half.b { clip-path: polygon(0 62%, 100% 38%, 100% 100%, 0 100%); animation: cutB .9s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes cutT { 20% { transform: translate(-6%, -10%) rotate(-5deg); } 100% { opacity: 0; transform: translate(-80%, -120%) rotate(-32deg); } }
@keyframes cutB { 20% { transform: translate(6%, 10%) rotate(4deg); } 100% { opacity: 0; transform: translate(90%, 100%) rotate(26deg); } }
.slash { position: absolute; left: -10%; top: 48%; width: 120%; height: 4px; border-radius: 99px; background: #fff; box-shadow: 0 0 16px 4px rgba(255, 255, 255, .7); transform: rotate(-22deg) scaleX(0); transform-origin: left; animation: slash .4s ease-out forwards; pointer-events: none; z-index: 3; }
@keyframes slash { 60% { transform: rotate(-22deg) scaleX(1); opacity: 1; } 100% { transform: rotate(-22deg) scaleX(1); opacity: 0; } }
.minus { position: absolute; right: 8px; top: 4px; font: 800 22px/1 var(--display); color: var(--coral); pointer-events: none; animation: floatUp 1.1s ease-out forwards; z-index: 3; }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(40%) scale(.7); } 20% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-130%); } }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-4px) rotate(-1deg); } 50% { transform: translateX(4px) rotate(1deg); } 75% { transform: translateX(-2px); } }

/* sheets (dialogs) */
.scrim { position: fixed; inset: 0; z-index: 80; display: grid; place-items: end center; background: rgba(10, 1, 4, .55); backdrop-filter: blur(4px); animation: fade .2s; }
@media (min-width: 700px) { .scrim { place-items: center; } }
@keyframes fade { from { opacity: 0; } }
.sheet { width: min(460px, 100%); max-height: 88dvh; overflow: auto; padding: 22px; border-radius: 26px 26px 0 0; background: var(--s1); box-shadow: inset 0 0 0 1px var(--line); display: grid; gap: 16px; animation: up .3s var(--ease); }
@media (min-width: 700px) { .sheet { border-radius: 26px; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet h3 { font: 700 21px/1.2 var(--display); }
.sheet p { color: var(--fg2); }
.stepper { display: grid; grid-template-columns: 64px 1fr 64px; gap: 10px; align-items: center; }
.stepper button { height: 64px; border-radius: 18px; background: var(--s2); font: 700 28px/1 var(--display); box-shadow: inset 0 0 0 1px var(--line); }
.stepper input { height: 64px; text-align: center; border: 0; border-radius: 18px; background: var(--bg); font: 700 32px/1 var(--display); box-shadow: inset 0 0 0 1px var(--line); width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hist { display: grid; gap: 2px; }
.hist p { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 13.5px; color: var(--fg); }
.hist i { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: 13px; }
.hist .k-in { background: rgba(94, 220, 235, .16); color: var(--app); }
.hist .k-out { background: rgba(255, 51, 102, .16); color: var(--coral); }
.hist .k-move { background: rgba(245, 184, 61, .16); color: #F5B83D; }
.hist time { color: var(--fg3); font-size: 12px; font-family: var(--mono); }
.token { font: 500 13px/1.4 var(--mono); padding: 12px; border-radius: 12px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); word-break: break-all; user-select: all; }

#toasts { position: fixed; left: 50%; bottom: 20px; z-index: 90; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100% - 24px)); }
.toast { padding: 12px 16px; border-radius: 14px; background: var(--fg); color: var(--bg); font-weight: 600; font-size: 14px; box-shadow: 0 16px 30px -12px rgba(0, 0, 0, .6); animation: up .3s var(--ease); }
.toast.bad { background: var(--coral); color: #fff; }

@media (max-width: 980px) {
  .floor { grid-template-columns: 1fr; }
  .in-lane .cards { grid-auto-flow: column; grid-auto-columns: minmax(200px, 70%); overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
  .in-lane .gr { scroll-snap-align: start; }
  .out-lane.drop { position: sticky; bottom: 10px; top: auto; z-index: 5; }
  .out-hole { min-height: 74px; margin-bottom: 0; grid-auto-flow: column; }
  .out-lane .cards { display: none; }
  .top .btn.ghost { padding: 0 10px; }
  .bins { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) { #btnSheet, #btnOut { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
