/* ============ CRR Inventory — styles ============ */
:root {
  --teal: #0d6e6e; --teal-soft: #e2f1f0; --teal-deep: #0a4d4d;
  --bg: #f4f7f8; --panel: #ffffff; --ink: #15302f; --ink2: #3d5453;
  --muted: #8a9a9a; --line: #e7eef0; --line2: #eef3f4;
  --ok: #3a7d44; --warn: #c98a3a; --bad: #b4544e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,42,46,.04), 0 6px 20px rgba(16,42,46,.06);
  --row-pad: 12px 16px;
  --sans: "IBM Plex Sans Thai", "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; letter-spacing: -0.003em; }
.mono { font-family: var(--mono); font-feature-settings: "tnum"; letter-spacing: 0; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #d3dde0; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #bfccd0; }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }
.app-top { grid-template-columns: 1fr; }

/* ---------- Sidebar ---------- */
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 11px; padding: 20px 20px; }
.brand-side { flex-direction: column; align-items: flex-start; gap: 9px; padding: 22px 20px 18px; }
.brand-img { width: 156px; height: auto; display: block; }
.brand-side .brand-sub { font-size: 11px; }
.brand-top { padding: 0; }
.brand-img-sm { height: 40px; width: auto; display: block; }
.brand-logo { width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(150deg, var(--teal), var(--teal-deep)); display: grid; place-items: center; box-shadow: 0 4px 12px color-mix(in oklab, var(--teal) 30%, transparent); flex: 0 0 auto; }
.brand-name { font-size: 17px; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
.brand-name span { font-weight: 400; color: var(--muted); }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.nav { display: flex; flex-direction: column; gap: 3px; padding: 8px 12px; flex: 1; }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 11px; color: var(--ink2); font-size: 14.5px; font-weight: 500; transition: all .18s ease; }
.nav-item:hover { background: var(--line2); color: var(--ink); }
.nav-item.on { background: var(--teal-soft); color: var(--teal-deep); font-weight: 600; }
.nav-item.on svg { color: var(--teal); }
.nav-ind { position: absolute; left: -12px; top: 50%; transform: translateY(-50%); width: 4px; height: 22px; background: var(--teal); border-radius: 0 4px 4px 0; }
.sidebar-foot { padding: 14px; border-top: 1px solid var(--line); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 11px; transition: background .18s; }
.user-chip:hover { background: var(--line2); }
.avatar { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(150deg, var(--teal), var(--teal-deep)); display: grid; place-items: center; flex: 0 0 auto; }
.avatar.sm { width: 32px; height: 32px; border-radius: 9px; }
.user-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.user-role { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- Topbar nav variant ---------- */
.topbar { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 64px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .brand { padding: 0; gap: 10px; }
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav-item { display: flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--ink2); transition: all .16s; }
.topnav-item:hover { background: var(--line2); }
.topnav-item.on { background: var(--teal-soft); color: var(--teal-deep); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* ---------- Appbar (sidebar mode) ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.appbar { display: flex; align-items: center; gap: 16px; padding: 14px 28px; background: color-mix(in oklab, var(--bg) 70%, white); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.appbar-search { flex: 1; max-width: 460px; }
.appbar-right { margin-left: auto; display: flex; gap: 8px; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: var(--ink2); transition: all .16s; }
.icon-btn:hover { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.badge-dot-abs { position: absolute; top: 9px; right: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); border: 2px solid var(--panel); }
.kbd { font-family: var(--mono); font-size: 11px; color: var(--muted); background: var(--line2); padding: 2px 7px; border-radius: 6px; margin-left: auto; }

/* ---------- Content ---------- */
.content { padding: 28px; position: relative; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.screen { max-width: 1280px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-title { font-size: 26px; font-weight: 700; margin: 0; letter-spacing: -0.025em; }
.page-sub { font-size: 13.5px; color: var(--muted); margin: 5px 0 0; }
.page-head-actions { display: flex; gap: 10px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 10px 16px; border-radius: 11px; font-size: 13.5px; font-weight: 600; transition: all .18s ease; white-space: nowrap; }
.btn.sm { padding: 7px 12px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; padding: 13px; font-size: 15px; margin-top: 14px; }
.btn-primary { background: var(--teal); color: #fff; box-shadow: 0 4px 12px color-mix(in oklab, var(--teal) 28%, transparent); }
.btn-primary:hover { background: var(--teal-deep); transform: translateY(-1px); box-shadow: 0 6px 16px color-mix(in oklab, var(--teal) 34%, transparent); }
.btn-primary:disabled { opacity: .45; pointer-events: none; }
.btn-success { background: var(--ok); color: #fff; }
.btn-ghost { background: var(--panel); color: var(--ink2); box-shadow: 0 0 0 1px var(--line); }
.btn-ghost:hover { box-shadow: 0 0 0 1px #d4dee0; color: var(--ink); background: #fbfdfd; }
.link-btn { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; font-weight: 600; color: var(--teal); transition: gap .16s; }
.link-btn:hover { gap: 6px; }
.back-link { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 600; color: var(--ink2); margin-bottom: 16px; transition: gap .16s; }
.back-link:hover { gap: 10px; color: var(--teal); }

/* ---------- Cards ---------- */
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid color-mix(in oklab, var(--line) 60%, transparent); }
.card.pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 15.5px; font-weight: 700; margin: 0; }
.card-tag { font-size: 11.5px; color: var(--muted); background: var(--line2); padding: 4px 10px; border-radius: 20px; font-weight: 500; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi-card { padding: 18px; transition: transform .2s, box-shadow .2s; }
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(16,42,46,.1); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.kpi-ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; }
.kpi-value { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; display: flex; align-items: baseline; gap: 6px; }
.kpi-unit { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.kpi-label { font-size: 13px; color: var(--ink2); margin-top: 7px; font-weight: 500; white-space: nowrap; }
.kpi-delta { font-size: 11.5px; margin-top: 3px; font-weight: 600; }

/* ---------- Dashboard grid ---------- */
.dash-grid { display: grid; grid-template-columns: 0.9fr 1fr 1.1fr; gap: 16px; }
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut-num { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; }
.donut-cap { font-size: 11px; color: var(--muted); }
.legend { display: flex; flex-direction: column; gap: 9px; flex: 1; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.legend-label { color: var(--ink2); flex: 1; white-space: nowrap; }
.legend-val { font-weight: 700; }

/* ---------- Bars ---------- */
.bars { display: flex; flex-direction: column; gap: 13px; }
.barrow-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.barrow-label { font-size: 13px; color: var(--ink2); font-weight: 500; white-space: nowrap; }
.barrow-val { font-size: 14px; font-weight: 700; }
.barrow-sub { font-size: 11px; color: var(--muted); font-weight: 400; }
.barrow-track { height: 8px; background: var(--line2); border-radius: 6px; overflow: hidden; }
.barrow-fill { height: 100%; border-radius: 6px; transition: width 1s cubic-bezier(.3,.8,.3,1); }
@keyframes grow { from { width: 0 !important; } }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.tl-row { display: flex; align-items: flex-start; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line2); }
.tl-row:last-child { border-bottom: none; padding-bottom: 0; }
.tl-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 auto; background: var(--line2); color: var(--ink2); }
.tl-transfer { background: #ebeef6; color: #4f6dab; }
.tl-checkout { background: var(--teal-soft); color: var(--teal); }
.tl-checkin { background: #e6f2e9; color: var(--ok); }
.tl-count { background: #e6f2e9; color: var(--ok); }
.tl-repair, .tl-service { background: #fbf0df; color: var(--warn); }
.tl-body { flex: 1; min-width: 0; }
.tl-main { font-size: 13.5px; color: var(--ink); }
.tl-main strong { font-weight: 600; }
.tl-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tl-time { font-size: 11.5px; color: var(--muted); white-space: nowrap; flex: 0 0 auto; }
.qr-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 700; color: var(--teal); background: var(--teal-soft); padding: 1px 6px; border-radius: 5px; margin-left: 6px; font-family: var(--mono); vertical-align: middle; }
.manual-chip { font-size: 11px; color: var(--muted); }

/* ---------- Badge ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }

/* ---------- Photo placeholder ---------- */
.photo-ph { position: relative; overflow: hidden; display: grid; place-items: center; background: #f3f6f7; }
.photo-ph-icon { position: relative; opacity: .5; }
.photo-ph-label { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); font-size: 9.5px; color: var(--muted); background: rgba(255,255,255,.8); padding: 2px 8px; border-radius: 5px; white-space: nowrap; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 9px; background: var(--panel); border-radius: 11px; padding: 0 14px; height: 42px; box-shadow: 0 0 0 1px var(--line); transition: box-shadow .16s; }
.search:focus-within { box-shadow: 0 0 0 2px var(--teal); }
.search input { border: none; outline: none; background: none; font-size: 14px; width: 230px; color: var(--ink); }
.search input::placeholder { color: var(--muted); }
.seg { display: inline-flex; background: var(--panel); border-radius: 11px; padding: 4px; box-shadow: 0 0 0 1px var(--line); gap: 2px; }
.seg-lg { margin-bottom: 18px; }
.seg-sm { margin-bottom: 14px; }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink2); transition: all .16s; white-space: nowrap; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.on { background: var(--teal); color: #fff; box-shadow: 0 2px 6px color-mix(in oklab, var(--teal) 26%, transparent); }
.seg-lg .seg-btn { padding: 9px 18px; font-size: 13.5px; }
.select { display: flex; align-items: center; gap: 7px; background: var(--panel); border-radius: 11px; padding: 0 12px; height: 42px; box-shadow: 0 0 0 1px var(--line); position: relative; }
.select select { border: none; outline: none; background: none; font-size: 13.5px; font-weight: 500; color: var(--ink); padding-right: 4px; -webkit-appearance: none; appearance: none; }
.viewtoggle { display: inline-flex; background: var(--panel); border-radius: 11px; padding: 4px; box-shadow: 0 0 0 1px var(--line); gap: 2px; margin-left: auto; }
.viewtoggle button { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); transition: all .16s; }
.viewtoggle button.on { background: var(--teal-soft); color: var(--teal); }

/* ---------- Asset grid ---------- */
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 16px; }
.asset-card { text-align: left; overflow: hidden; padding: 0; transition: transform .2s, box-shadow .2s; display: block; }
.asset-card:hover { transform: translateY(-4px); box-shadow: 0 16px 34px rgba(16,42,46,.12); }
.asset-card:hover .photo-ph-icon { opacity: .75; transform: scale(1.06); transition: all .3s; }
.asset-card-body { padding: 14px 15px 15px; }
.asset-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.asset-id { font-size: 11px; color: var(--muted); }
.asset-card-name { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.asset-card-brand { font-size: 12px; color: var(--muted); margin-top: 2px; margin-bottom: 12px; }
.asset-card-foot { display: flex; align-items: center; justify-content: space-between; }
.dept-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; color: var(--dc); background: color-mix(in oklab, var(--dc) 12%, white); padding: 4px 9px; border-radius: 7px; white-space: nowrap; }
.dept-chip.sm { font-size: 11px; padding: 3px 8px; }
.health { font-size: 13px; font-weight: 700; }

/* ---------- Table ---------- */
.table-card { overflow: hidden; }
.dtable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.dtable thead th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 13px 16px; border-bottom: 1px solid var(--line); background: #fbfdfd; }
.dtable tbody td { padding: var(--row-pad); border-bottom: 1px solid var(--line2); vertical-align: middle; }
.dtable tbody tr { transition: background .14s; cursor: pointer; }
.dtable tbody tr:hover { background: var(--teal-soft); }
.dtable tbody tr:last-child td { border-bottom: none; }
.td-name { font-weight: 600; color: var(--ink); }
.td-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.td-date { font-size: 12.5px; color: var(--ink2); }
.health-bar { width: 64px; height: 6px; background: var(--line2); border-radius: 4px; overflow: hidden; }
.health-bar.lg { width: 100%; height: 8px; }
.health-fill { height: 100%; border-radius: 4px; transition: width .9s cubic-bezier(.3,.8,.3,1); }
.pad-head { padding: 16px 20px; margin: 0; border-bottom: 1px solid var(--line); }

/* ---------- Detail ---------- */
.detail-grid { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
.detail-photo-card { overflow: hidden; padding: 0; margin-bottom: 16px; }
.detail-thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 10px; }
.thumb { border-radius: 8px; overflow: hidden; cursor: pointer; opacity: .7; transition: opacity .16s; }
.thumb:hover { opacity: 1; }
.qr-card { display: flex; gap: 16px; align-items: center; }
.qr-box { padding: 8px; background: #fff; border-radius: 12px; box-shadow: 0 0 0 1px var(--line); }
.qr-card-title { font-size: 14px; font-weight: 700; }
.qr-card-id { font-size: 12px; color: var(--teal); margin: 2px 0 6px; }
.qr-card-note { font-size: 11.5px; color: var(--muted); margin: 0 0 10px; line-height: 1.5; }
.qr-card-btns { display: flex; gap: 8px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid var(--line2); margin-bottom: 18px; }
.detail-cat { font-size: 11px; color: var(--teal); font-weight: 600; letter-spacing: 0.06em; }
.detail-name { font-size: 24px; font-weight: 700; margin: 4px 0 5px; letter-spacing: -0.02em; line-height: 1.25; }
.detail-brand { font-size: 13.5px; color: var(--ink2); }
.detail-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.dm-item { display: flex; flex-direction: column; gap: 7px; }
.dm-label { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.dm-value { font-size: 14.5px; font-weight: 700; }
.dm-health { display: flex; align-items: center; gap: 10px; }
.action-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.action-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px; border-radius: 12px; font-size: 14px; font-weight: 600; color: var(--ac); background: color-mix(in oklab, var(--ac) 9%, white); box-shadow: 0 0 0 1px color-mix(in oklab, var(--ac) 18%, transparent); transition: all .18s; }
.action-btn:hover { background: var(--ac); color: #fff; transform: translateY(-2px); box-shadow: 0 8px 18px color-mix(in oklab, var(--ac) 30%, transparent); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .16s; }
.tab:hover { color: var(--ink2); }
.tab.on { color: var(--teal); border-bottom-color: var(--teal); }
.spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px 24px; }
.spec-row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line2); }
.spec-k { font-size: 13px; color: var(--muted); }
.spec-v { font-size: 13.5px; font-weight: 600; text-align: right; }

/* ---------- Location ---------- */
.loc-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.live-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--ok); background: #e6f2e9; padding: 7px 13px; border-radius: 20px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--ok) 50%, transparent); } 50% { box-shadow: 0 0 0 5px transparent; } }
.dept-map { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.dept-tile { text-align: left; padding: 16px; border-radius: 14px; box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--dc) 22%, transparent); transition: all .2s; position: relative; }
.dept-tile:hover { transform: translateY(-3px); box-shadow: inset 0 0 0 1px var(--dc), 0 10px 22px color-mix(in oklab, var(--dc) 22%, transparent); }
.dept-tile.on { box-shadow: inset 0 0 0 2px var(--dc), 0 10px 24px color-mix(in oklab, var(--dc) 26%, transparent); }
.dept-tile-top { display: flex; justify-content: space-between; align-items: center; }
.dept-tile-id { font-size: 11px; font-weight: 700; color: var(--dc); }
.dept-tile-alert { font-size: 10px; font-weight: 700; color: #fff; background: var(--bad); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: grid; place-items: center; }
.dept-tile-count { font-size: 30px; font-weight: 700; color: var(--ink); letter-spacing: -0.03em; margin-top: 8px; }
.dept-tile-name { font-size: 13px; font-weight: 600; color: var(--ink); margin-top: 2px; }
.dept-tile-floor { font-size: 11px; color: var(--ink2); opacity: .7; margin-top: 1px; }
.map-legend { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; font-size: 11px; color: var(--muted); }
.heat-scale { display: flex; align-items: center; gap: 8px; }
.heat-bar { width: 120px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, color-mix(in oklab, var(--teal) 12%, white), var(--teal)); }
.loc-detail-head { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--line2); margin-bottom: 16px; }
.loc-detail-badge { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; font-family: var(--mono); flex: 0 0 auto; }
.loc-detail-name { font-size: 17px; font-weight: 700; margin: 0; }
.loc-detail-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.loc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.loc-stat { text-align: center; padding: 12px; background: var(--line2); border-radius: 12px; }
.loc-stat-num { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; }
.loc-stat-lbl { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.loc-list { display: flex; flex-direction: column; gap: 7px; max-height: 360px; overflow-y: auto; padding-right: 4px; }
.loc-item { display: flex; align-items: center; gap: 11px; padding: 10px; border-radius: 11px; text-align: left; transition: background .14s; }
.loc-item:hover { background: var(--teal-soft); }
.loc-item-ph { width: 36px; height: 36px; border-radius: 9px; background: var(--line2); display: grid; place-items: center; flex: 0 0 auto; }
.loc-item-body { flex: 1; min-width: 0; }
.loc-item-name { font-size: 13.5px; font-weight: 600; }
.loc-item-id { font-size: 11px; color: var(--muted); margin-top: 1px; }
.empty { text-align: center; color: var(--muted); padding: 30px; font-size: 13px; }

/* ---------- Reports ---------- */
.rep-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.mini-stat { padding: 16px 18px; }
.mini-stat-v { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
.mini-stat-u { font-size: 12px; font-weight: 500; color: var(--muted); }
.mini-stat-l { font-size: 12.5px; color: var(--ink2); margin-top: 3px; }
.matrix-scroll { overflow-x: auto; }
.matrix { min-width: 720px; }
.matrix td.num, .matrix th.num { text-align: center; padding: 8px; }
.mhead { font-weight: 700; font-family: var(--mono); font-size: 12px; }
.heat-cell { display: inline-grid; place-items: center; min-width: 30px; height: 28px; padding: 0 8px; border-radius: 8px; font-weight: 700; font-size: 13px; }
.zero { color: #cdd8da; }
.sticky-col { position: sticky; left: 0; background: var(--panel); z-index: 2; }
.dtable thead .sticky-col { background: #fbfdfd; }
.total-col { font-weight: 700; background: #fbfdfd; }
.matrix tfoot td { padding: 12px 8px; font-weight: 700; border-top: 2px solid var(--line); background: #fbfdfd; text-align: center; }
.matrix tfoot td.sticky-col { text-align: left; }
.grand { color: var(--teal); font-size: 15px; }
.mv-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 7px; background: var(--line2); color: var(--ink2); }
.mv-transfer { background: #ebeef6; color: #4f6dab; }
.mv-checkout { background: var(--teal-soft); color: var(--teal); }
.mv-checkin, .mv-count { background: #e6f2e9; color: var(--ok); }
.mv-repair { background: #fbf0df; color: var(--warn); }
.td-flow { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; }

/* ---------- Scan screen (desktop) ---------- */
.scan-screen { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: 1fr 360px; gap: 40px; align-items: center; min-height: 70vh; }
.scan-intro .page-title { font-size: 32px; }
.scan-intro .page-sub { font-size: 15px; max-width: 460px; line-height: 1.6; }
.scan-feats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 26px 0; }
.scan-feat { display: flex; gap: 12px; align-items: flex-start; padding: 14px; background: var(--panel); border-radius: 13px; box-shadow: var(--shadow); }
.scan-feat-ico { width: 40px; height: 40px; border-radius: 11px; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; flex: 0 0 auto; }
.scan-feat-t { font-size: 14px; font-weight: 700; }
.scan-feat-s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.scan-note { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--teal); font-weight: 600; }

/* ---------- Phone ---------- */
.scan-phone-wrap { display: grid; place-items: center; }
.phone { width: 320px; height: 660px; background: #0b1f1f; border-radius: 42px; padding: 11px; box-shadow: 0 30px 70px rgba(11,31,31,.4), inset 0 0 0 2px #1a3433; position: relative; }
.phone-notch { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); width: 110px; height: 26px; background: #0b1f1f; border-radius: 14px; z-index: 30; }
.phone-screen { width: 100%; height: 100%; background: var(--bg); border-radius: 32px; overflow: hidden; position: relative; display: flex; flex-direction: column; }
.m-statusbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 22px 6px; font-size: 12px; font-weight: 700; color: var(--ink); }
.m-sb-icons { display: flex; gap: 5px; }

/* mobile scan view */
.m-scan { position: absolute; inset: 0; background: linear-gradient(170deg, #0e2e2e, #07201f); display: flex; flex-direction: column; }
.m-scan-head { display: flex; align-items: center; justify-content: space-between; padding: 44px 18px 10px; }
.m-scan-title { font-size: 15px; font-weight: 600; color: #fff; }
.m-icon-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,.1); }
.m-viewfinder { flex: 1; display: grid; place-items: center; }
.m-vf-frame { width: 220px; height: 220px; position: relative; border-radius: 22px; background: rgba(255,255,255,.03); }
.corner { position: absolute; width: 34px; height: 34px; border: 3px solid #2bd4c4; }
.corner.tl { top: -2px; left: -2px; border-right: none; border-bottom: none; border-radius: 14px 0 0 0; }
.corner.tr { top: -2px; right: -2px; border-left: none; border-bottom: none; border-radius: 0 14px 0 0; }
.corner.bl { bottom: -2px; left: -2px; border-right: none; border-top: none; border-radius: 0 0 0 14px; }
.corner.br { bottom: -2px; right: -2px; border-left: none; border-top: none; border-radius: 0 0 14px 0; }
.scanline { position: absolute; left: 12px; right: 12px; height: 3px; border-radius: 3px; background: linear-gradient(90deg, transparent, #2bd4c4, transparent); box-shadow: 0 0 16px #2bd4c4; animation: scan 1.7s ease-in-out infinite; }
@keyframes scan { 0%,100% { top: 14px; } 50% { top: calc(100% - 18px); } }
.m-vf-hint { position: absolute; bottom: -34px; left: 50%; transform: translateX(-50%); font-size: 11px; color: rgba(255,255,255,.7); white-space: nowrap; }
.m-scan-foot { padding: 24px; text-align: center; }
.m-scan-tip { font-size: 12.5px; color: rgba(255,255,255,.6); margin: 0; line-height: 1.5; }

/* mobile result sheet */
.m-sheet { position: absolute; inset: 0; top: auto; bottom: 0; background: var(--panel); border-radius: 26px 26px 32px 32px; padding: 18px 18px 22px; overflow-y: auto; max-height: calc(100% - 30px); box-shadow: 0 -10px 40px rgba(0,0,0,.15); }
.m-action-sheet { top: 30px; max-height: calc(100% - 30px); }
@keyframes sheetUp { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
.m-result-top { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 14px; }
.m-success { width: 48px; height: 48px; border-radius: 50%; background: var(--ok); display: grid; place-items: center; }
@keyframes popCheck { from { transform: scale(0); } to { transform: scale(1); } }
.m-found-id { font-size: 12px; color: var(--teal); font-weight: 600; }
.m-asset-name { font-size: 18px; font-weight: 700; margin-top: 12px; letter-spacing: -0.02em; line-height: 1.3; }
.m-asset-brand { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.m-asset-meta { display: flex; gap: 8px; align-items: center; margin: 12px 0 16px; }
.m-actions { display: flex; flex-direction: column; gap: 8px; }
.m-action { display: flex; align-items: center; gap: 12px; padding: 13px; border-radius: 13px; text-align: left; background: var(--bg); transition: all .16s; }
.m-action:hover, .m-action:active { background: color-mix(in oklab, var(--ac) 10%, white); transform: scale(.99); }
.m-action-ico { width: 40px; height: 40px; border-radius: 11px; background: color-mix(in oklab, var(--ac) 14%, white); color: var(--ac); display: grid; place-items: center; flex: 0 0 auto; }
.m-action-text { flex: 1; }
.m-action-label { font-size: 14.5px; font-weight: 700; }
.m-action-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.m-rescan { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; margin-top: 14px; padding: 12px; border-radius: 12px; font-size: 13.5px; font-weight: 600; color: var(--teal); background: var(--teal-soft); }

/* mobile action shells */
.m-action-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 14px; border-bottom: 1px solid var(--line2); margin-bottom: 16px; }
.m-action-title { font-size: 15.5px; font-weight: 700; color: var(--ac); }
.m-back { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--bg); color: var(--ink2); }
.m-spec { margin: 14px 0; }
.m-spec-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line2); font-size: 13px; }
.m-spec-row span:first-child { color: var(--muted); }
.m-spec-v { font-weight: 600; }
.m-move-from { display: flex; align-items: center; justify-content: space-between; padding: 14px; background: var(--bg); border-radius: 12px; }
.m-move-lbl { font-size: 12px; font-weight: 600; color: var(--muted); }
.m-move-arrow { text-align: center; margin: 10px 0; }
.m-dept-pick { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.m-dept-opt { display: flex; align-items: center; gap: 10px; padding: 11px; border-radius: 12px; background: var(--bg); transition: all .14s; box-shadow: inset 0 0 0 1px transparent; }
.m-dept-opt.on { box-shadow: inset 0 0 0 2px var(--dc); background: color-mix(in oklab, var(--dc) 8%, white); }
.m-dept-badge { width: 34px; height: 34px; border-radius: 9px; color: #fff; font-size: 11px; font-weight: 700; font-family: var(--mono); display: grid; place-items: center; flex: 0 0 auto; }
.m-dept-nm { flex: 1; font-size: 13.5px; font-weight: 600; text-align: left; }
.m-count-card { text-align: center; padding: 22px; background: var(--bg); border-radius: 16px; }
.m-count-ring { width: 62px; height: 62px; border-radius: 50%; background: #e6f2e9; display: grid; place-items: center; margin: 0 auto 12px; }
.m-count-name { font-size: 16px; font-weight: 700; }
.m-count-id { font-size: 11.5px; color: var(--teal); font-weight: 600; margin-top: 3px; }
.m-count-loc { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.m-count-q { text-align: center; font-size: 13.5px; color: var(--ink2); margin: 16px 0; }
.m-count-btns { display: flex; gap: 10px; }
.m-count-btns .btn { margin-top: 0; }
.m-pri { display: flex; gap: 8px; margin: 8px 0 16px; }
.m-pri-btn { flex: 1; padding: 11px; border-radius: 11px; font-size: 13px; font-weight: 600; color: var(--ink2); background: var(--bg); box-shadow: inset 0 0 0 1px transparent; transition: all .14s; }
.m-pri-btn.on { color: var(--pc); box-shadow: inset 0 0 0 2px var(--pc); background: color-mix(in oklab, var(--pc) 8%, white); }
.m-issue-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.m-issue { padding: 8px 13px; border-radius: 20px; font-size: 12.5px; font-weight: 500; background: var(--bg); color: var(--ink2); box-shadow: inset 0 0 0 1px var(--line); transition: all .14s; }
.m-issue.on { background: #fbf0df; color: var(--warn); box-shadow: inset 0 0 0 2px var(--warn); font-weight: 600; }
.m-toast { position: absolute; bottom: 22px; left: 16px; right: 16px; background: var(--ink); color: #fff; padding: 13px 16px; border-radius: 13px; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 9px; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.3); animation: toastUp .3s cubic-bezier(.2,1,.3,1); }
@keyframes toastUp { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- FAB ---------- */
.fab-mobile { position: fixed; bottom: 28px; right: 28px; width: 58px; height: 58px; border-radius: 18px; background: linear-gradient(150deg, var(--teal), var(--teal-deep)); display: grid; place-items: center; box-shadow: 0 10px 26px color-mix(in oklab, var(--teal) 40%, transparent); z-index: 40; transition: transform .2s; animation: fabIn .5s cubic-bezier(.2,1.3,.4,1) both; }
.fab-mobile:hover { transform: translateY(-3px) scale(1.04); }
@keyframes fabIn { from { transform: scale(0) rotate(-30deg); } to { transform: none; } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .dash-grid > .card:last-child { grid-column: 1 / -1; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid, .loc-grid, .scan-screen { grid-template-columns: 1fr; }
}

/* ---------- Modal: Add Asset ---------- */
.modal-scrim { position: fixed; inset: 0; background: rgba(13,28,30,.42); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 200; padding: 24px; }
.modal { width: 100%; max-width: 680px; background: var(--panel); border-radius: 18px; box-shadow: 0 30px 80px rgba(13,28,30,.3); max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 22px 24px; border-bottom: 1px solid var(--line2); }
.modal-title { font-size: 19px; font-weight: 700; margin: 0; }
.modal-sub { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }
.modal-x { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--ink2); transition: all .15s; }
.modal-x:hover { background: var(--line2); }
.modal-body { padding: 22px 24px; display: grid; grid-template-columns: 190px 1fr; gap: 22px; overflow-y: auto; }
.form-photo { display: flex; flex-direction: column; gap: 12px; }
.upload { aspect-ratio: 1; border-radius: 14px; border: 2px dashed var(--line); display: grid; place-items: center; cursor: pointer; overflow: hidden; background: var(--bg); transition: all .16s; }
.upload:hover { border-color: var(--teal); background: var(--teal-soft); }
.upload img { width: 100%; height: 100%; object-fit: cover; }
.upload-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.upload-empty svg { color: var(--teal); }
.upload-hint { font-size: 10px; opacity: .7; }
.id-preview { background: var(--teal-soft); border-radius: 11px; padding: 11px 13px; }
.id-preview-lbl { display: block; font-size: 10.5px; color: var(--teal-deep); font-weight: 600; }
.id-preview-val { display: block; font-size: 14px; font-weight: 700; color: var(--teal-deep); margin-top: 2px; }
.form-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-content: start; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink2); }
.field label b { color: var(--bad); }
.field input, .select-box select { width: 100%; height: 42px; border-radius: 10px; border: none; box-shadow: inset 0 0 0 1px var(--line); padding: 0 13px; font-size: 14px; color: var(--ink); background: var(--panel); outline: none; transition: box-shadow .15s; }
.field input:focus, .select-box select:focus { box-shadow: inset 0 0 0 2px var(--teal); }
.field input::placeholder { color: #b9c6c8; }
.select-box { position: relative; }
.select-box select { -webkit-appearance: none; appearance: none; padding-right: 34px; cursor: pointer; }
.select-box svg { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line2); background: #fbfdfd; }

/* uploaded photos + new flag */
.asset-photo { width: 100%; height: 128px; object-fit: cover; display: block; }
.detail-photo-img { width: 100%; height: 300px; object-fit: cover; display: block; }
.asset-card { position: relative; }
.new-flag { position: absolute; top: 10px; left: 10px; font-size: 10.5px; font-weight: 700; color: #fff; background: var(--teal); padding: 3px 9px; border-radius: 7px; box-shadow: 0 2px 8px color-mix(in oklab, var(--teal) 36%, transparent); }

/* app toast */
.app-toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 13px 20px; border-radius: 13px; font-size: 13.5px; font-weight: 500; display: flex; align-items: center; gap: 9px; z-index: 220; box-shadow: 0 12px 34px rgba(0,0,0,.28); }
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) { .modal-body { grid-template-columns: 1fr; } .form-fields { grid-template-columns: 1fr; } }

/* Entrance animations — gated so content is never trapped invisible
   during print/PDF export, reduced-motion, or a frozen timeline. */
@media (prefers-reduced-motion: no-preference) {
  .content { animation: fadeUp .4s cubic-bezier(.2,.7,.3,1); }
  .stagger { animation: pop .5s both cubic-bezier(.2,.7,.3,1); }
  .m-sheet { animation: sheetUp .35s cubic-bezier(.2,.8,.3,1); }
  .m-success { animation: popCheck .5s cubic-bezier(.2,1.4,.4,1) both; }
  .modal { animation: modalIn .28s cubic-bezier(.2,.9,.3,1); }
  .app-toast { animation: toastUp .3s cubic-bezier(.2,1,.3,1); }
}

/* Failsafe: if the animation clock never advances (frozen timeline /
   throttled tab / capture harness), force the visible end-state via
   !important so content can never be stranded at opacity:0. */
html.reveal-fallback .content,
html.reveal-fallback .stagger,
html.reveal-fallback .m-sheet,
html.reveal-fallback .m-success { opacity: 1 !important; }
