/* Activity Monitor — mobile-first, native-style UI (iOS look, works on Android). */
:root {
  --bg: #f2f2f7; --bg2: #ffffff; --bg3: #f2f2f7; --fill: rgba(120,120,128,.12); --fill2: rgba(120,120,128,.2);
  --label: #000; --label2: rgba(60,60,67,.6); --label3: rgba(60,60,67,.3); --sep: rgba(60,60,67,.18);
  --tint: #007aff; --green: #34c759; --orange: #ff9500; --blue: #007aff; --red: #ff3b30; --gray: #8e8e93; --gray2: #aeaeb2;
  --active: var(--green); --idle: var(--orange); --away: var(--blue); --absent: var(--red); --off_shift: #c7c7cc; --unknown: #636366;
  --ok: var(--green); --warn: var(--orange); --critical: var(--red);
  --bar-bg: rgba(249,249,249,.86); --radius: 12px; --tabbar-h: 50px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000; --bg2: #1c1c1e; --bg3: #2c2c2e; --fill: rgba(118,118,128,.24); --fill2: rgba(118,118,128,.32);
    --label: #fff; --label2: rgba(235,235,245,.6); --label3: rgba(235,235,245,.3); --sep: rgba(84,84,88,.65);
    --tint: #0a84ff; --green: #30d158; --orange: #ff9f0a; --blue: #0a84ff; --red: #ff453a; --gray: #8e8e93;
    --off_shift: #48484a; --unknown: #8e8e93; --bar-bg: rgba(22,22,24,.86);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--label); font: 17px/1.3 var(--font); -webkit-font-smoothing: antialiased; }
body { overscroll-behavior-y: none; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--tint); text-decoration: none; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- layout ---------- */
#app { min-height: 100%; }
.page { min-height: 100vh; padding: calc(var(--safe-top) + 44px) 0 calc(var(--tabbar-h) + var(--safe-bottom) + 24px); }
/* --pad = side gutter; grids below size themselves from .content's width (container queries), not the window's */
.content { --pad: 16px; max-width: 760px; margin: 0 auto; padding: 0 var(--pad); container-type: inline-size; }
.content.wide { max-width: 1100px; }

/* nav bar with collapsing large title */
.navbar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; padding-top: var(--safe-top); height: calc(44px + var(--safe-top));
  display: flex; align-items: center; justify-content: space-between; padding-left: 8px; padding-right: 8px;
  background: transparent; transition: background .2s, border-color .2s; border-bottom: .5px solid transparent; }
.navbar.solid { background: var(--bar-bg); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-bottom-color: var(--sep); }
.navbar .title { position: absolute; left: 50%; transform: translateX(-50%); font-weight: 600; font-size: 17px; opacity: 0; transition: opacity .2s; white-space: nowrap; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
.navbar.solid .title, .navbar.always .title { opacity: 1; }
.nav-btn { display: inline-flex; align-items: center; gap: 2px; color: var(--tint); font-size: 17px; min-height: 44px; min-width: 44px; padding: 0 8px; }
.nav-btn svg { width: 22px; height: 22px; }
.nav-right { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.large-title { font-size: 34px; font-weight: 700; letter-spacing: .37px; margin: 4px 0 2px; line-height: 1.15; }
.subtitle { color: var(--label2); font-size: 15px; margin-bottom: 14px; }
.badge-dot { position: relative; }
.badge-dot[data-count]:not([data-count="0"])::after { content: attr(data-count); position: absolute; top: 6px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: #fff; font-size: 12px; font-weight: 600; line-height: 18px; text-align: center; }

/* tab bar (bottom on phones, sidebar on wide screens) */
.tabbar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  display: flex; background: var(--bar-bg); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: .5px solid var(--sep); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--gray); font-size: 10px; font-weight: 500; position: relative; }
.tab svg { width: 26px; height: 26px; }
.tab.on { color: var(--tint); }
.tab .tab-badge { position: absolute; top: 3px; left: calc(50% + 6px); min-width: 17px; height: 17px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 17px; padding: 0 4px; text-align: center; }
.brand { display: none; }

@media (min-width: 900px) {
  :root { --tabbar-h: 0px; }
  .tabbar { top: 0; right: auto; width: 240px; height: 100%; flex-direction: column; justify-content: flex-start; padding: 16px 12px; gap: 2px; border-top: 0; border-right: .5px solid var(--sep); }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 8px 10px 18px; }
  .brand img { width: 32px; height: 32px; border-radius: 8px; }
  .tab { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px; font-size: 15px; padding: 9px 12px; border-radius: 10px; color: var(--label); }
  .tab svg { width: 22px; height: 22px; color: var(--tint); }
  .tab.on { background: var(--tint); color: #fff; }
  .tab.on svg { color: #fff; }
  .tab .tab-badge { position: static; margin-left: auto; }
  .page, .navbar { margin-left: 240px; }
  .navbar { left: 240px; margin-left: 0; }
}

/* ---------- grouped lists ---------- */
.section { margin: 22px 0 0; }
.section-h { display: flex; justify-content: space-between; align-items: baseline; padding: 0 16px 7px; color: var(--label2); font-size: 13px; text-transform: uppercase; letter-spacing: -.08px; }
.section-h a, .section-h button { text-transform: none; font-size: 15px; line-height: 1; color: var(--tint); }
.section-f { padding: 7px 16px 0; color: var(--label2); font-size: 13px; }
.list { background: var(--bg2); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 16px; position: relative; width: 100%; text-align: left; }
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: var(--inset, 16px); border-top: .5px solid var(--sep); }
.row.icon-row { --inset: 60px; }
.row.avatar-row { --inset: 68px; }
button.row:active, a.row:active { background: var(--fill); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--label); }
.row .s { font-size: 13px; color: var(--label2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .v { color: var(--label2); font-size: 17px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.chev { width: 8px; height: 13px; color: var(--label3); flex: none; }
.row-icon { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; color: #fff; flex: none; }
.row-icon svg { width: 19px; height: 19px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 15px; color: #fff; flex: none; position: relative; }
.avatar.lg { width: 72px; height: 72px; font-size: 28px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; color: #fff; }
.pill.soft { color: var(--label); background: var(--fill); font-weight: 500; }
.destructive { color: var(--red) !important; }
.tinted { color: var(--tint) !important; }

/* ---------- cards / tiles ---------- */
.card { background: var(--bg2); border-radius: var(--radius); padding: 16px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@container (min-width: 720px) { .tiles { grid-template-columns: repeat(6, 1fr); } }
.tile { background: var(--bg2); border-radius: var(--radius); padding: 12px; text-align: left; display: flex; flex-direction: column; gap: 6px; min-height: 84px; }
.tile .n { font-size: 28px; font-weight: 700; line-height: 1; }
.tile .l { font-size: 13px; color: var(--label2); font-weight: 500; display: flex; align-items: center; gap: 6px; white-space: nowrap; min-width: 0; }
button.tile:active { transform: scale(.97); }
.stack { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--fill); }
.stack i { display: block; height: 100%; }
.big-stat { display: flex; align-items: baseline; gap: 8px; }
.big-stat b { font-size: 44px; font-weight: 700; letter-spacing: -.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--label2); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.banner { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--bg2); }
.banner .row-icon { width: 36px; height: 36px; border-radius: 50%; }
.grid2 { display: grid; gap: 0 22px; }
@container (min-width: 760px) { .grid2 { grid-template-columns: 1fr 1fr; align-items: start; } }

/* ---------- camera views ---------- */
.cam { position: relative; background: #111; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; }
.cam img { width: 100%; height: 100%; object-fit: contain; display: block; background: #111; }
.cam svg.ov { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cam .cam-tag { position: absolute; left: 8px; top: 8px; display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 6px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 12px; font-weight: 600; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.cam .cam-tag.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: pulse 1.6s infinite; }
.cam .cam-msg { position: absolute; inset: 0; display: grid; place-items: center; color: #aaa; font-size: 15px; text-align: center; padding: 16px; }
@keyframes pulse { 50% { opacity: .3; } }
.cams { display: grid; gap: 16px; }
@container (min-width: 560px) { .cams { grid-template-columns: 1fr 1fr; } }
@container (min-width: 1200px) { .cams { grid-template-columns: repeat(3, 1fr); } }
.cam-card { background: var(--bg2); border-radius: var(--radius); overflow: hidden; text-align: left; width: 100%; }
.cam-card .cam { border-radius: 0; }
.cam-card .meta { padding: 10px 14px 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; background: var(--fill); font-size: 13px; }
/* swipe strip on narrow screens: bleeds to the screen edge, but cards snap to the gutter, not the edge */
.hscroll { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 0 var(--pad) 4px; margin: 0 calc(-1 * var(--pad));
  scroll-padding-inline: var(--pad); scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { flex: 0 0 82%; scroll-snap-align: start; }
@container (min-width: 520px) { .hscroll > * { flex-basis: calc(50% - 6px); } }
/* wide: a plain grid, no scrolling */
@container (min-width: 760px) { .hscroll { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; overflow: visible; margin: 0; padding: 0; } }
.fullscreen-cam:fullscreen { background: #000; display: grid; place-items: center; }
.fullscreen-cam:fullscreen .cam { width: 100%; height: 100%; aspect-ratio: auto; border-radius: 0; }

/* ---------- controls ---------- */
.seg { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { flex: 1; padding: 6px 8px; border-radius: 7px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.seg button.on { background: var(--bg2); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); font-weight: 600; }
@media (prefers-color-scheme: dark) { .seg button.on { background: #636366; } }
.search { display: flex; align-items: center; gap: 6px; background: var(--fill); border-radius: 10px; padding: 0 8px; height: 36px; margin-bottom: 10px; }
.search svg { width: 16px; height: 16px; color: var(--label2); flex: none; }
.search input { flex: 1; border: 0; background: none; outline: none; font-size: 17px; min-width: 0; }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--fill2); transition: background .25s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 3px 1px rgba(0,0,0,.06); transition: transform .25s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 50px; border-radius: 12px; background: var(--tint); color: #fff; font-weight: 600; font-size: 17px; }
.btn.gray { background: var(--fill); color: var(--tint); }
.btn:disabled { opacity: .5; }
.btn:active { opacity: .7; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 36px; height: 36px; border-radius: 50%; background: var(--fill); color: var(--tint); display: grid; place-items: center; }
.stepper button svg { width: 16px; height: 16px; }
.stepper .date { flex: 1; text-align: center; font-weight: 600; position: relative; }
.stepper input[type=date] { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.field { display: block; width: 100%; border: 0; outline: none; background: none; font-size: 17px; padding: 12px 16px; min-height: 44px; }
.field + .field { border-top: .5px solid var(--sep); }

/* ---------- timeline ---------- */
.tl { position: relative; height: 26px; border-radius: 6px; background: var(--fill); overflow: hidden; }
.tl i { position: absolute; top: 0; bottom: 0; }
.tl.sm { height: 8px; border-radius: 4px; margin-top: 6px; }
.tl-axis { position: relative; height: 18px; font-size: 11px; color: var(--label2); margin-top: 4px; }
.tl-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.tl-axis span:first-child { transform: none; }
.tl-axis span:last-child { transform: translateX(-100%); }
.meter { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; transition: width .4s; }

/* ---------- sheet / toast / misc ---------- */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4); opacity: 0; transition: opacity .25s; }
.backdrop.show { opacity: 1; }
.sheet { position: fixed; z-index: 51; left: 8px; right: 8px; bottom: calc(8px + var(--safe-bottom)); transform: translateY(120%); transition: transform .3s cubic-bezier(.2,.9,.3,1); max-width: 520px; margin: 0 auto; }
.sheet.show { transform: none; }
.sheet .group { background: var(--bar-bg); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); border-radius: 14px; overflow: hidden; }
.sheet .group + .group { margin-top: 8px; }
.sheet .head { padding: 14px 16px; text-align: center; color: var(--label2); font-size: 13px; border-bottom: .5px solid var(--sep); }
.sheet .act { display: block; width: 100%; padding: 17px; text-align: center; color: var(--tint); font-size: 20px; }
.sheet .act + .act { border-top: .5px solid var(--sep); }
.sheet .act.cancel { font-weight: 600; background: var(--bg2); }
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px); transform: translate(-50%, 20px); opacity: 0;
  background: rgba(30,30,30,.92); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 15px; transition: all .25s; pointer-events: none; max-width: 90%; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty { text-align: center; color: var(--label2); padding: 28px 16px; font-size: 15px; }
.empty svg { width: 44px; height: 44px; color: var(--label3); display: block; margin: 0 auto 8px; }
.skeleton { background: linear-gradient(90deg, var(--fill) 25%, var(--fill2) 50%, var(--fill) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius); }
@keyframes sk { to { background-position: -200% 0; } }
.ptr { position: fixed; top: calc(var(--safe-top) + 50px); left: 50%; transform: translateX(-50%); z-index: 15; width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid var(--fill2); border-top-color: var(--label2); opacity: 0; transition: opacity .2s; }
.ptr.on { opacity: 1; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: translateX(-50%) rotate(360deg); } }
.page-enter { animation: enter .28s cubic-bezier(.2,.9,.3,1); }
@keyframes enter { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }
.small { font-size: 13px; color: var(--label2); }
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 8px 0 4px; }
.hero h1 { font-size: 26px; margin: 4px 0 0; }
/* desk detail header: one compact card instead of a tall centred stack */
.desk-head { display: flex; align-items: center; gap: 14px; margin-top: 8px; padding: 14px 16px; background: var(--bg2); border-radius: var(--radius); }
.desk-head .avatar { width: 52px; height: 52px; font-size: 20px; }
.desk-head .main { flex: 1; min-width: 0; }
.desk-head h1 { font-size: 22px; line-height: 1.2; margin: 0 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.desk-head .status { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .box { width: 100%; max-width: 380px; text-align: center; }
.login img { width: 84px; height: 84px; border-radius: 20px; box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.login h1 { font-size: 28px; margin: 18px 0 4px; }
.login .list { text-align: left; margin: 26px 0 16px; }
.login .demo-login { margin-top: 20px; padding: 14px 16px; border-radius: var(--radius); background: var(--bg2); display: grid; gap: 8px; font-size: 15px; }
.login .demo-login .btn { min-height: 44px; font-size: 15px; }
.login .err { color: var(--red); font-size: 15px; min-height: 20px; margin-bottom: 8px; }

/* attendance month: one cell per day */
.att-month { padding-top: 12px; padding-bottom: 6px; }
.att-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.att-head .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-strip { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 2px; margin-top: 8px; }
.att-strip i { height: 18px; border-radius: 3px; background: var(--fill); }
.att-strip i[data-d] { cursor: pointer; }
@media (hover: hover) { .att-strip i[data-d]:hover { outline: 2px solid var(--label2); outline-offset: 1px; } }

/* zone helper */
.draw { position: relative; touch-action: none; cursor: crosshair; }
.draw svg { position: absolute; inset: 0; width: 100%; height: 100%; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.row.acked .t { color: var(--label2); }
.grid2 > *, .content > * { min-width: 0; }
.row.wrap .t { white-space: normal; overflow: visible; font-size: 15px; line-height: 1.3; }
.cam-card { color: var(--label); display: block; }
.btn svg { width: 20px; height: 20px; flex: none; }
a.row, a.row b { color: var(--label); }

/* ---------- desktop: use the width (sidebar already switches on at 900px) ---------- */
/* .split: one column; two (live | day, video | controls) once the content is wide enough */
.split { display: grid; gap: 0 28px; }
.split > * { container-type: inline-size; min-width: 0; }
@container (min-width: 900px) {
  .split { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); grid-template-rows: auto auto auto 1fr; align-items: start; }
  .split > .side { grid-column: 2; grid-row: 1 / -1; }
  .split.cam-split { grid-template-columns: minmax(0, 1.8fr) minmax(300px, 1fr); }
  .split > .side > .section:first-child { margin-top: 8px; }
}
/* row lists that tile into columns (desks, report desks) */
@container (min-width: 700px) {
  .cols .list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .5px; background: var(--sep); }
  .cols .list > * { background: var(--bg2); }
  .cols .list > .row::before { display: none; }
  .cols .list > .empty { grid-column: 1 / -1; }
}
@media (min-width: 900px) {
  .content { --pad: 32px; max-width: 1320px; }
  .content.narrow { max-width: 860px; }
  .page { padding-top: 56px; padding-bottom: 48px; }
  /* controls keep a comfortable width instead of stretching across the screen */
  .search, .content > .seg, #d-seg .seg, .content > .section > .stepper, .side > .section > .stepper { max-width: 560px; }
  .content .btn { width: auto; min-width: 200px; padding: 0 24px; display: inline-flex; }
  button.row:hover, a.row:hover, button.tile:hover, .cam-card:hover { background: var(--fill); }
}
