/* SMART POS — HUD shell (theme, layout, HANA panel) */
:root {
  --bg: #04070d;
  --bg-2: #08101c;
  --panel: rgba(9, 18, 32, 0.78);
  --panel-solid: #0a1424;
  --raise: rgba(20, 40, 66, 0.55);
  --line: rgba(84, 200, 255, 0.16);
  --line-hi: rgba(84, 220, 255, 0.45);
  --cyan: #3be3ff;
  --blue: #2a86ff;
  --magenta: #ff3fbf;
  --lime: #a8ff4a;
  --amber: #ffb547;
  --red: #ff4f6d;
  --text: #dff4ff;
  --muted: #7d9db3;
  --dim: #4a6478;
  --glow: 0 0 18px rgba(59, 227, 255, 0.35);
  --radius: 10px;
  --f-head: 'Rajdhani', 'Avenir Next Condensed', system-ui, sans-serif;
  --f-body: 'Inter', system-ui, -apple-system, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --rail-w: 84px;
  --hana-w: 340px;
  --top-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1200px 700px at 70% -10%, #0c2240 0%, transparent 60%),
              radial-gradient(900px 600px at -10% 110%, #2a0b33 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--f-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.grid-bg {
  position: fixed; inset: 0; pointer-events: none; opacity: .35;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 75%);
}

/* ---------- shell ---------- */
.app {
  position: relative;
  display: grid;
  grid-template: var(--top-h) 1fr / var(--rail-w) 1fr var(--hana-w);
  grid-template-areas: "top top top" "rail view hana";
  height: 100vh; height: 100dvh;
}
.app.hana-off { grid-template-columns: var(--rail-w) 1fr 0; }
.app.hana-off .hana { visibility: hidden; }

/* ---------- top bar ---------- */
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 20px;
  padding: 0 18px 0 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 18, 32, .95), rgba(6, 12, 22, .8));
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { height: 44px; width: auto; border-radius: 6px; filter: drop-shadow(0 0 10px rgba(59,227,255,.25)); }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font: 700 24px/1 var(--f-head); letter-spacing: .08em; }
.brand-name b { color: var(--cyan); margin-left: 6px; text-shadow: var(--glow); }
.brand-sub { font: 500 11px var(--f-mono); color: var(--muted); letter-spacing: .06em; margin-top: 4px; }

.sys { display: flex; gap: 6px; flex: 1; justify-content: center; flex-wrap: nowrap; overflow: hidden; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px;
  font: 500 11px var(--f-mono); color: var(--muted); white-space: nowrap;
  background: rgba(10, 22, 38, .6);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.on { background: var(--lime); box-shadow: 0 0 8px var(--lime); }
.dot.warn { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.dot.off { background: var(--dim); }

.top-right { display: flex; align-items: center; gap: 16px; }
.clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
#clock-time { white-space: nowrap; font: 600 20px var(--f-mono); color: var(--cyan); text-shadow: var(--glow); }
#clock-date { font: 500 11px var(--f-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.hana-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line-hi); background: rgba(59, 227, 255, .08);
  font: 700 13px var(--f-head); letter-spacing: .14em;
}
.hana-toggle:hover { background: rgba(59, 227, 255, .16); }
.mini-orb {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 15%, var(--cyan) 40%, transparent 72%);
  box-shadow: 0 0 10px var(--cyan); animation: pulse 2.4s ease-in-out infinite;
}

/* ---------- nav rail ---------- */
.rail {
  grid-area: rail;
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 8px;
  border-right: 1px solid var(--line);
  background: rgba(5, 11, 20, .7);
  overflow-y: auto;
}
.rail a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px; border-radius: 8px;
  color: var(--muted); text-decoration: none;
  font: 600 11px var(--f-head); letter-spacing: .08em; text-transform: uppercase;
}
.rail a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.rail a:hover { color: var(--text); background: var(--raise); }
.rail a[aria-current="page"] { color: var(--cyan); background: rgba(59, 227, 255, .08); }
.rail a[aria-current="page"]::before {
  content: ""; position: absolute; left: -8px; top: 10px; bottom: 10px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--cyan); box-shadow: var(--glow);
}
.rail .badge {
  position: absolute; top: 4px; right: 8px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--magenta); color: #fff;
  font: 600 10px/16px var(--f-mono); text-align: center;
}

/* ---------- main view ---------- */
.view { grid-area: view; overflow: auto; padding: 20px 22px 28px; min-width: 0; }
.view:focus { outline: none; }

/* ---------- shared HUD pieces ---------- */
.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
}
/* corner brackets */
.panel.hud::before, .panel.hud::after {
  content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none;
  border-color: var(--cyan); border-style: solid; opacity: .7;
}
.panel.hud::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; border-radius: var(--radius) 0 0 0; }
.panel.hud::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; border-radius: 0 0 var(--radius) 0; }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.view-head h1 { margin: 0; font: 700 28px/1 var(--f-head); letter-spacing: .06em; text-transform: uppercase; }
.view-head h1 small { display: block; margin-top: 6px; font: 500 12px var(--f-mono); color: var(--muted); letter-spacing: .04em; text-transform: none; }
.kicker { font: 600 11px var(--f-mono); letter-spacing: .14em; color: var(--cyan); text-transform: uppercase; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; border-radius: 8px;
  border: 1px solid var(--line-hi); background: rgba(59, 227, 255, .08);
  font: 600 14px var(--f-head); letter-spacing: .08em; text-transform: uppercase;
}
.btn:hover { background: rgba(59, 227, 255, .18); }
.btn.primary { background: linear-gradient(135deg, var(--cyan), var(--blue)); color: #021018; border-color: transparent; box-shadow: var(--glow); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.magenta { border-color: rgba(255, 63, 191, .6); background: rgba(255, 63, 191, .12); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn:disabled { opacity: .4; cursor: not-allowed; filter: none; }

.tag {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font: 600 10px var(--f-mono); letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid var(--line); color: var(--muted);
}
.tag.example { border-color: rgba(255, 181, 71, .5); color: var(--amber); }
.tag.ok { border-color: rgba(168, 255, 74, .5); color: var(--lime); }
.tag.warn { border-color: rgba(255, 181, 71, .5); color: var(--amber); }
.tag.bad { border-color: rgba(255, 79, 109, .6); color: var(--red); }
.mono { font-family: var(--f-mono); }
.muted { color: var(--muted); }

/* ---------- HANA panel ---------- */
.hana {
  grid-area: hana;
  display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 18, 34, .92), rgba(6, 10, 20, .92));
}
.hana-head { display: flex; align-items: center; gap: 14px; padding: 18px 16px 12px; }
.orb { position: relative; width: 96px; height: 96px; flex: none; }
.orb svg { width: 100%; height: 100%; overflow: visible; }
.orb .ring { fill: none; stroke: var(--cyan); transform-origin: 100px 100px; }
.orb .r1 { stroke-width: 1; stroke-dasharray: 4 10; opacity: .5; animation: spin 24s linear infinite; }
.orb .r2 { stroke-width: 2; stroke-dasharray: 120 40 20 40; opacity: .8; animation: spin 10s linear infinite reverse; }
.orb .r3 { stroke-width: 1; stroke-dasharray: 2 6; opacity: .6; animation: spin 16s linear infinite; }
.orb .r4 { stroke-width: 3; stroke-dasharray: 60 254; stroke: var(--magenta); opacity: .8; animation: spin 4s linear infinite; }
.orb .core { fill: rgba(59, 227, 255, .25); stroke: var(--cyan); stroke-width: 1.5; filter: drop-shadow(0 0 12px var(--cyan)); animation: pulse 2.4s ease-in-out infinite; transform-origin: 100px 100px; }
.orb-label { position: absolute; inset: 0; display: grid; place-items: center; font: 700 12px var(--f-head); letter-spacing: .2em; color: #fff; text-shadow: 0 0 8px var(--cyan); }
.orb[data-state="thinking"] .r2 { animation-duration: 2s; }
.orb[data-state="thinking"] .r4 { animation-duration: 1s; }
.orb[data-state="alert"] .ring, .orb[data-state="alert"] .core { stroke: var(--amber); }
.orb[data-state="alert"] .core { fill: rgba(255, 181, 71, .25); filter: drop-shadow(0 0 12px var(--amber)); }

.hana-title { font: 700 22px/1 var(--f-head); letter-spacing: .14em; }
.hana-title span { display: block; margin-top: 4px; font: 500 11px var(--f-mono); letter-spacing: .06em; color: var(--muted); }
.hana-state { margin-top: 8px; font: 500 12px var(--f-mono); color: var(--amber); }

.hana-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 16px 12px; }
.hana-quick button {
  padding: 7px 8px; border-radius: 6px; border: 1px solid var(--line);
  background: rgba(16, 32, 54, .6); color: var(--text);
  font: 600 12px var(--f-head); letter-spacing: .08em; text-transform: uppercase;
}
.hana-quick button:hover { border-color: var(--line-hi); background: rgba(59, 227, 255, .1); }

.hana-feed { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 16px 12px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); }
.msg { padding: 11px 13px; border-radius: 8px; background: rgba(14, 28, 48, .78); border: 1px solid var(--line); font-size: 14px; line-height: 1.55; color: #eaf6ff; }
.msg .msg-text { white-space: pre-line; overflow-wrap: anywhere; }
.msg time { display: block; font: 600 10.5px var(--f-mono); color: var(--muted); margin-bottom: 5px; letter-spacing: .08em; }
/* Easy reading: list lines, bold prices, the newest reply appearing word by word. */
.msg .ln { display: block; }
.msg .gap { display: block; height: .5em; }
.msg .li { position: relative; padding-left: 16px; margin: 2px 0; }
.msg .li::before { content: ""; position: absolute; left: 2px; top: .65em; width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.msg .price { color: var(--cyan); font-weight: 700; white-space: nowrap; }
.msg .w { opacity: 0; animation: msg-word .3s ease-out forwards; }
@keyframes msg-word { from { opacity: 0; filter: blur(3px); } to { opacity: 1; filter: none; } }
.msg.ai { border-color: rgba(59, 227, 255, .55); box-shadow: inset 3px 0 0 var(--cyan); }
.msg.ai time { color: var(--cyan); }
.msg.typing { align-self: flex-start; }
.msg.typing .dots { display: inline-flex; gap: 6px; padding: 4px 2px; }
.msg.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 6px var(--cyan); animation: msg-dot 1s ease-in-out infinite; }
.msg.typing i:nth-child(2) { animation-delay: .15s; }
.msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes msg-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .msg .w { animation: none; opacity: 1; } .msg.typing i { animation: none; opacity: .7; } }
.hana-sound { margin-left: auto; align-self: flex-start; flex: none; width: 34px; height: 34px; display: grid; place-items: center; padding: 0; border-radius: 8px; border: 1px solid var(--line); background: rgba(59, 227, 255, .06); color: var(--cyan); cursor: pointer; }
.hana-sound:hover { border-color: var(--line-hi); }
.hana-sound svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hana-sound svg path:first-child { fill: currentColor; }
.hana-sound .off, .hana-sound.muted .on { display: none; }
.hana-sound.muted .off { display: inline; }
.hana-sound.muted { color: var(--dim); }
.msg.warn { border-color: rgba(255, 181, 71, .45); background: rgba(60, 40, 10, .35); }
.msg.ok { border-color: rgba(168, 255, 74, .35); }
.msg.user { align-self: flex-end; max-width: 85%; background: rgba(42, 134, 255, .16); border-color: rgba(42, 134, 255, .45); }

.hana-input { display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.hana-input input {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(4, 10, 18, .8);
}
.hana-input input:focus { border-color: var(--line-hi); outline: none; box-shadow: var(--glow); }
.hana-input button { width: 42px; border-radius: 8px; border: 0; background: linear-gradient(135deg, var(--cyan), var(--blue)); color: #021018; font-weight: 700; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px);
  padding: 12px 18px; border-radius: 10px; opacity: 0; pointer-events: none;
  background: var(--panel-solid); border: 1px solid var(--line-hi); box-shadow: var(--glow);
  font: 600 14px var(--f-head); letter-spacing: .06em; transition: .25s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { transform: scale(.88); opacity: .75; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .app { grid-template-columns: var(--rail-w) 1fr 0; }
  .hana {
    position: fixed; top: var(--top-h); right: 0; bottom: 0; width: min(var(--hana-w), 92vw);
    z-index: 40; transform: translateX(100%); transition: transform .25s ease;
    box-shadow: -20px 0 40px rgba(0, 0, 0, .5);
  }
  .app.hana-open .hana { transform: none; }
  .app.hana-off .hana { visibility: visible; }
  .sys .chip span.lbl { display: none; }
}
@media (max-width: 760px) {
  :root { --top-h: 56px; }
  body { overflow: auto; }
  .app { grid-template: var(--top-h) 1fr 64px / 1fr; grid-template-areas: "top" "view" "rail"; }
  .brand-logo, .brand-sub, .sys, #clock-date { display: none; }
  .topbar { padding: 0 16px; }
  .rail { flex-direction: row; justify-content: space-around; padding: 6px; border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; }
  .rail a { flex: 1; min-width: 0; padding: 6px 0; font-size: 9px; letter-spacing: .02em; }
  .rail .badge { right: 2px; }
  .rail a[aria-current="page"]::before { display: none; }
  .view { padding: 16px; }
  .hana { top: var(--top-h); bottom: 64px; width: 100vw; }
}
