/* FactoryIQ live tracking dashboard — dark navy with the FactoryIQ app's blue and silver accents. Sized for a
   1080p/4K monitor (vw/clamp units), still usable on a laptop. */
:root {
    --bg: #0E1622;
    --bg-2: #16202F;
    --card: #1B2738;
    --card-2: #202D42;
    --line: rgba(139, 152, 171, 0.16);
    --text: #F1F5F9;
    --muted: #8B98AB;
    --faint: #6C7888;
    --accent: #8FC4FF;      /* light blue (app icon highlight) */
    --accent-2: #2F8CFF;    /* FactoryIQ blue */
    --silver: #B9C3D1;
    --blue: #4D9BE8;
    --blue-2: #1659BE;
    --green: #34D399;
    --red: #F87171;
    --font: "Helvetica Neue", Helvetica, Arial, "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --r: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    background: radial-gradient(1200px 700px at 85% -10%, rgba(77, 155, 232, 0.10), transparent 60%),
                radial-gradient(900px 600px at -10% 110%, rgba(47, 140, 255, 0.08), transparent 60%),
                var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---- ConnectIQ logo (brand/, from connectiq.asia) + FactoryIQ product name ---- */
/* Lockup: hexagon mark + "CONNECT IQ" lettering; --logo-h is the mark's height. */
.ciq-logo { --logo-h: clamp(52px, 4.4vw, 92px); display: flex; align-items: center; gap: calc(var(--logo-h) * 0.28); }
.ciq-logo.small { --logo-h: clamp(30px, 2.4vw, 48px); }
.ciq-mark { height: var(--logo-h); width: var(--logo-h); display: block; }
.ciq-text { height: calc(var(--logo-h) * 0.42); width: auto; display: block; }
.product { white-space: nowrap; }
.product .iq { color: var(--accent); }

/* ---- sign-in ---- */
.signin {
    height: 100%;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    align-items: center;
    gap: 4vw;
    padding: 6vh 7vw;
}
.signin h1 { font-size: clamp(34px, 3.6vw, 76px); margin: 4vh 0 1vh; letter-spacing: -0.02em; line-height: 1.1; }
.lead { color: var(--muted); font-size: clamp(16px, 1.4vw, 28px); margin: 0 0 4vh; }
.steps { list-style: none; padding: 0; margin: 0 0 4vh; display: grid; gap: 2vh; }
.steps li { display: flex; align-items: center; gap: 18px; font-size: clamp(16px, 1.35vw, 28px); }
.step-n {
    flex: none; width: 2.1em; height: 2.1em; border-radius: 50%;
    display: grid; place-items: center; font-weight: 700; font-size: 0.85em;
    color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.steps strong { color: var(--accent); }
.fine { color: var(--faint); font-size: clamp(13px, 0.95vw, 18px); max-width: 36em; }
.signin-qr { display: flex; flex-direction: column; align-items: center; gap: 3vh; }
.qr-card {
    background: #fff; border-radius: 24px; padding: clamp(18px, 2vw, 40px);
    box-shadow: 0 0 0 1px rgba(47, 140, 255, 0.35), 0 30px 80px rgba(0, 0, 0, 0.45), 0 0 60px rgba(47, 140, 255, 0.18);
    width: min(36vw, 62vh); min-width: 260px;
}
.qr { aspect-ratio: 1; width: 100%; display: grid; place-items: center; }
.qr svg { width: 100%; height: 100%; display: block; }
.qr-status { color: #334155; text-align: center; font-size: clamp(13px, 1vw, 20px); margin-top: 14px; min-height: 1.4em; }
.qr-timer { height: 5px; border-radius: 3px; background: #E2E8F0; margin-top: 12px; overflow: hidden; }
.qr-timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--blue), var(--blue-2)); transform-origin: left; transition: transform 1s linear; }
.powered { color: var(--faint); font-size: clamp(12px, 0.9vw, 18px); }
.powered strong { color: var(--muted); }

/* ---- dashboard layout ---- */
.dash { height: 100%; display: grid; grid-template-rows: auto auto 1fr auto; gap: 1.6vh; padding: 2vh 2vw 1.4vh; }
.topbar { display: flex; align-items: center; gap: 2vw; }
.brand { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand-sep { width: 1px; height: 42px; background: var(--line); }
.company-name { font-size: clamp(16px, 1.25vw, 26px); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 28vw; }
.subtitle { color: var(--muted); font-size: clamp(11px, 0.8vw, 16px); text-transform: uppercase; letter-spacing: 0.14em; margin-top: 3px; }
.floor-tabs { display: flex; gap: 8px; flex: 1; justify-content: center; flex-wrap: wrap; }
.floor-tab {
    border: 1px solid var(--line); background: var(--card); color: var(--muted);
    padding: 8px 18px; border-radius: 999px; font-size: clamp(13px, 0.9vw, 18px);
}
.floor-tab.active { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; font-weight: 700; }
.top-right { display: flex; align-items: center; gap: 22px; }
.live { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: clamp(12px, 0.85vw, 17px); }
.live .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); }
.live.ok .dot { background: var(--green); box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); animation: pulse 2s infinite; }
.live.bad .dot { background: var(--red); }
.live.bad { color: var(--red); }
.clock { font-variant-numeric: tabular-nums; font-size: clamp(20px, 1.6vw, 34px); font-weight: 600; letter-spacing: 0.02em; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); } 70% { box-shadow: 0 0 0 10px rgba(52, 211, 153, 0); } 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); } }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.2vw; }
.kpi { background: linear-gradient(180deg, var(--card-2), var(--card)); border: 1px solid var(--line); border-radius: var(--r); padding: 1.6vh 1.4vw; }
.kpi-label { color: var(--muted); font-size: clamp(11px, 0.8vw, 16px); text-transform: uppercase; letter-spacing: 0.1em; }
.kpi-value { font-size: clamp(26px, 2.6vw, 56px); font-weight: 700; margin-top: 0.6vh; font-variant-numeric: tabular-nums; }
.kpi-value.small { font-size: clamp(18px, 1.6vw, 34px); }
.kpi:first-child .kpi-value { background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.main { display: grid; grid-template-columns: 1fr minmax(320px, 27vw); gap: 1.2vw; min-height: 0; }

/* ---- floor ---- */
.floor-wrap { position: relative; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; min-height: 0; }
.floor-wrap::before {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 40px 40px; opacity: 0.35;
}
.floor { position: absolute; inset: 0; }
.box {
    position: absolute; border-radius: 12px; border: 1.5px solid rgba(139, 152, 171, 0.35);
    background: rgba(32, 45, 66, 0.92); display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; padding: 6px; text-align: center; cursor: pointer; transition: border-color 0.4s, background 0.4s, box-shadow 0.4s;
    overflow: hidden;
}
.box:hover { border-color: var(--blue); }
.box.has { border-color: rgba(47, 140, 255, 0.75); background: linear-gradient(160deg, rgba(47, 140, 255, 0.22), rgba(32, 45, 66, 0.95) 70%); }
.box.selected { box-shadow: 0 0 0 3px var(--text), 0 0 30px rgba(143, 196, 255, 0.35); }
.box.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(143, 196, 255, 0.9); } 100% { box-shadow: 0 0 0 22px rgba(143, 196, 255, 0); } }
.box-name { font-weight: 600; color: var(--text); line-height: 1.15; word-break: break-word; }
.box-count { font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; color: var(--muted); }
.box.has .box-count { color: var(--accent); }
.box-unit { color: var(--faint); text-transform: uppercase; letter-spacing: 0.1em; }
.floor-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 10%; color: var(--muted); font-size: clamp(15px, 1.1vw, 22px); line-height: 1.5; }
.unplaced {
    position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    color: var(--muted); font-size: clamp(11px, 0.8vw, 15px);
}
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px; color: var(--text); }
.chip b { color: var(--accent); margin-left: 6px; }

/* ---- side ---- */
.side { display: flex; flex-direction: column; gap: 1.2vh; min-height: 0; }
.search { display: flex; gap: 8px; }
.search input {
    flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--text);
    padding: 12px 14px; font: inherit; font-size: clamp(14px, 0.95vw, 19px);
}
.search input:focus { outline: none; border-color: var(--blue); }
.search button { border: 0; border-radius: 10px; padding: 0 18px; background: linear-gradient(135deg, var(--blue), var(--blue-2)); font-weight: 600; }
.section-title { color: var(--muted); font-size: clamp(11px, 0.8vw, 16px); text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 1vh; }

.panel, .feed-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1.4vh 1vw; min-height: 0; }
.panel { display: flex; flex-direction: column; max-height: 62%; }
.panel.full { max-height: none; flex: 1; }
.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 1vh; }
.panel-titles { flex: 1; min-width: 0; }
.panel-title { font-weight: 700; font-size: clamp(16px, 1.15vw, 24px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-sub { color: var(--muted); font-size: clamp(12px, 0.8vw, 16px); margin-top: 2px; }
.icon-btn { background: transparent; border: 0; font-size: 28px; line-height: 1; padding: 2px 8px; color: var(--muted); }
.icon-btn:hover { color: var(--text); }
.panel-body { overflow-y: auto; min-height: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 4px; border-top: 1px solid var(--line); cursor: pointer; }
.row:hover { background: rgba(77, 155, 232, 0.07); }
.row-tag { font-weight: 700; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.row-meta { color: var(--muted); font-size: 0.9em; }
.muted { color: var(--muted); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.tl-item { position: relative; padding: 10px 0 12px 22px; border-left: 2px solid var(--line); }
.tl-item::before { content: ""; position: absolute; left: -7px; top: 14px; width: 12px; height: 12px; border-radius: 50%; background: var(--faint); }
.tl-item.now::before { background: var(--green); box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.2); }
.tl-loc { font-weight: 700; }
.tl-now { color: var(--green); font-weight: 600; margin-left: 8px; font-size: 0.85em; }
.tl-times { color: var(--muted); font-size: 0.9em; margin-top: 2px; }
.tl-dur { color: var(--accent); font-weight: 600; font-size: 0.9em; margin-top: 2px; }

.feed-box { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.feed { list-style: none; margin: 0; padding: 0; overflow: hidden; }
.feed li { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 9px 2px; border-top: 1px solid var(--line); animation: slide-in 0.5s ease-out; font-size: clamp(13px, 0.9vw, 18px); }
.feed li:first-child { border-top: 0; }
.feed-kind { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.feed-kind.in { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.feed-kind.move { background: rgba(77, 155, 232, 0.16); color: var(--blue); }
.feed-kind.out { background: rgba(248, 113, 113, 0.14); color: var(--red); }
.feed-text b { letter-spacing: 0.04em; }
.feed-time { color: var(--faint); font-variant-numeric: tabular-nums; font-size: 0.9em; }
.feed-empty { color: var(--faint); font-size: clamp(13px, 0.9vw, 17px); }
@keyframes slide-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.footer { display: flex; justify-content: space-between; color: var(--faint); font-size: clamp(11px, 0.75vw, 15px); }
.footer strong { color: var(--muted); }
.footer-actions { display: flex; gap: 18px; }
.link-btn { background: none; border: 0; color: var(--faint); padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); }

.toast {
    position: fixed; left: 50%; bottom: 5vh; transform: translateX(-50%); background: var(--card-2); border: 1px solid var(--line);
    padding: 12px 20px; border-radius: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4); font-size: clamp(13px, 0.95vw, 18px);
}

/* ---- smaller screens (laptop / tablet / phone) ---- */
@media (max-width: 1100px) {
    body { overflow: auto; }
    .signin { grid-template-columns: 1fr; padding: 5vh 6vw; gap: 4vh; height: auto; min-height: 100%; }
    .qr-card { width: min(80vw, 420px); }
    .dash { height: auto; min-height: 100%; }
    .topbar { flex-wrap: wrap; }
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .main { grid-template-columns: 1fr; }
    .floor-wrap { height: 60vh; }
    .feed-box { min-height: 240px; }
}
@media (max-width: 520px) {
    .dash { padding: 12px 16px; }
    .brand-sep, .subtitle { display: none; }
    .top-right { width: 100%; justify-content: space-between; }
}
