/* Door Access portal - mobile first, light/dark. No external fonts or assets (strict CSP). */
:root {
  --bg: #f4f5f8; --bg-2: #eceef3; --panel: #ffffff; --panel-2: #f8f9fb; --text: #111827; --muted: #6b7280; --line: #e4e7ec;
  --accent: #4f46e5; --accent-2: #6366f1; --accent-soft: #eef0ff; --on-accent: #fff;
  --ok: #059669; --ok-soft: #e6f7f0; --bad: #dc2626; --bad-soft: #fdecec; --warn: #b45309; --warn-soft: #fef4e2; --info: #2563eb; --info-soft: #e8f0fe;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .08);
  --r: 14px; --r-sm: 10px; --nav-h: 64px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f14; --bg-2: #151821; --panel: #161a23; --panel-2: #1b202b; --text: #e8eaf0; --muted: #98a1b2; --line: #262c39;
    --accent: #818cf8; --accent-2: #a5b4fc; --accent-soft: #23264a; --on-accent: #0d0f14;
    --ok: #34d399; --ok-soft: #10291f; --bad: #f87171; --bad-soft: #321517; --warn: #fbbf24; --warn-soft: #2f2410; --info: #60a5fa; --info-soft: #14233d;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f14; --bg-2: #151821; --panel: #161a23; --panel-2: #1b202b; --text: #e8eaf0; --muted: #98a1b2; --line: #262c39;
  --accent: #818cf8; --accent-2: #a5b4fc; --accent-soft: #23264a; --on-accent: #0d0f14;
  --ok: #34d399; --ok-soft: #10291f; --bad: #f87171; --bad-soft: #321517; --warn: #fbbf24; --warn-soft: #2f2410; --info: #60a5fa; --info-soft: #14233d;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; }
.spacer { flex: 1; }
.error { color: var(--bad); min-height: 1.2em; margin: 4px 0 0; font-size: 14px; }
.bad-text { color: var(--bad) !important; }
.lead { margin: 0; font-size: 15px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.tight { gap: 6px; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ------------------------------------------------ buttons, inputs */
button, input, select, textarea { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 14px;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); box-shadow: 0 1px 2px rgba(79,70,229,.3); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: var(--bad); border-color: transparent; color: #fff; }
.btn.danger:hover { filter: brightness(1.06); }
.btn.warn { background: var(--warn); border-color: transparent; color: var(--on-warn, #fff); }
:root[data-theme="dark"] { --on-warn: #1c1406; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --on-warn: #1c1406; } }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-2); }
.btn.danger.ghost { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn.lg { min-height: 48px; font-size: 16px; }
.btn.xl { min-height: 56px; font-size: 17px; padding: 12px 22px; border-radius: 14px; }
.btn.block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--text); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--bg-2); }
.icon-btn.danger { color: var(--bad); }

input, select, textarea {
  width: 100%; min-width: 0; min-height: 42px; padding: 9px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 16px; /* 16px stops iOS zoom */
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field > input, .field > textarea, .field > select, .field > .pw-wrap { font-weight: 400; color: var(--text); }
.field small { font-weight: 400; }
.code-input { font-family: var(--mono); font-size: 22px; letter-spacing: .35em; text-align: center; }
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { padding-right: 46px; }
.eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 38px; height: 36px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; }
.eye:hover { color: var(--text); background: var(--bg-2); }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--bg-2); color: var(--muted); white-space: nowrap; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn { min-height: 34px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--text); }
.chip-btn.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--bg-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.live-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--ok); background: var(--ok-soft); padding: 2px 9px 2px 6px; border-radius: 999px; }
.live-pill .ic { width: 14px; height: 14px; }

.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--bg-2); gap: 2px; }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 6px 10px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg-btn .ic { width: 16px; height: 16px; }
.seg-btn.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }

/* avatars */
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; color: #fff; letter-spacing: .02em; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.big { width: 64px; height: 64px; font-size: 22px; }
.hue0 { background: #6366f1; } .hue1 { background: #0ea5e9; } .hue2 { background: #10b981; } .hue3 { background: #f59e0b; }
.hue4 { background: #ef4444; } .hue5 { background: #8b5cf6; } .hue6 { background: #ec4899; } .hue7 { background: #14b8a6; }

/* ------------------------------------------------ login */
.login { position: fixed; inset: 0; overflow-y: auto; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent),
  radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--accent) 14%, transparent), transparent), var(--bg); }
.login-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px 24px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 24px; }
.login-card .muted { margin: -8px 0 6px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; flex: none; display: block; }
.brand-mark.big { width: 56px; height: 56px; border-radius: 14px; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }

/* ------------------------------------------------ shell */
.app { min-height: 100vh; min-height: 100dvh; }
.sidebar { display: none; }
.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.topbar h1 { font-size: 20px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back { margin-left: -8px; }
.hw { display: flex; gap: 6px; }
.open-door { min-height: 38px; padding: 6px 12px; }
.open-door.is-open { background: var(--ok); }
.view { padding: 16px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); max-width: 1240px; margin: 0 auto; outline: none; animation: fadein .2s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; text-decoration: none !important; }
.tab-item .ic { width: 23px; height: 23px; }
.tab-item.active { color: var(--accent); }
.tab-item.active .ic { stroke-width: 2.2; }

/* phones: compact top bar */
@media (max-width: 899px) {
  .hw .chip { padding: 4px; font-size: 0; gap: 0; }
  .hw .chip .dot { width: 10px; height: 10px; }
  .hw .chip.ok { display: none; }
  .open-door span { display: none; }
  .open-door { width: 40px; padding: 0; border-radius: 12px; }
  body[data-page="home"] .open-door { display: none; }
}

/* desktop: sidebar */
@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 248px 1fr; }
  .bottom-nav { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; padding: 18px 14px;
    background: var(--panel); border-right: 1px solid var(--line);
  }
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-size: 16px; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; text-decoration: none !important; }
  .nav-item:hover { background: var(--bg-2); color: var(--text); }
  .nav-item.active { background: var(--accent-soft); color: var(--accent); }
  .side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
  .side-actions { display: flex; flex-direction: column; gap: 2px; }
  .side-actions .btn { justify-content: flex-start; border: 0; color: var(--muted); }
  .side-actions .btn:hover { color: var(--text); }
  .me { display: flex; align-items: center; gap: 10px; font-weight: 600; padding: 0 4px; }
  .view { padding: 22px 28px 40px; }
  .topbar { padding: 14px 28px; }
  .topbar h1 { font-size: 22px; }
}

/* ------------------------------------------------ cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.card + .card, .section + .section { margin-top: 14px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h3 { font-size: 15px; font-weight: 700; }
.sec-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
.sec-ic .ic { width: 17px; height: 17px; }
.link { font-size: 14px; font-weight: 600; }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; list-style: none; }
.empty.big { padding: 40px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty.big .ic { width: 38px; height: 38px; opacity: .5; }

/* skeletons */
.skel, .skel-block { position: relative; overflow: hidden; background: var(--bg-2) !important; border-color: transparent !important; box-shadow: none !important; }
.skel::after, .skel-block::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--panel) 60%, transparent), transparent); animation: shimmer 1.2s infinite; }
.skel-block { min-height: 150px; border-radius: var(--r); }
.skel-block.tall { min-height: 320px; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ------------------------------------------------ home */
.home-grid { display: grid; gap: 14px; }
.home-grid .col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.home-grid .col > .card + .card { margin-top: 0; }
@media (min-width: 1100px) { .home-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; } }

.door-card { display: grid; grid-template-columns: auto 1fr; gap: 14px 16px; align-items: center; padding: 18px; position: relative; overflow: hidden; }
.door-card::before { content: ""; position: absolute; inset: 0; background: radial-gradient(500px 200px at 0% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent); pointer-events: none; }
.door-card.open::before { background: radial-gradient(500px 200px at 0% 0%, color-mix(in srgb, var(--ok) 18%, transparent), transparent); }
.door-visual { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.door-card.open .door-visual { background: var(--ok-soft); color: var(--ok); }
.door-visual .ic { width: 34px; height: 34px; stroke-width: 1.6; }
.eyebrow { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.door-state { font-size: 26px; font-weight: 800; line-height: 1.1; }
.door-card.open .door-state { color: var(--ok); }
.hw-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.door-card .btn.xl { grid-column: 1 / -1; width: 100%; }
@media (min-width: 640px) { .door-card { grid-template-columns: auto 1fr auto; } .door-card .btn.xl { grid-column: auto; width: auto; } }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); text-align: left; min-height: 104px; display: flex; flex-direction: column; gap: 2px; color: var(--text); }
.stat.click { cursor: pointer; font: inherit; }
.stat.click:hover { border-color: var(--accent); }
.stat-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--bg-2); color: var(--muted); margin-bottom: 6px; }
.stat-ic .ic { width: 17px; height: 17px; }
.stat.ok .stat-ic { background: var(--ok-soft); color: var(--ok); }
.stat.bad .stat-ic { background: var(--bad-soft); color: var(--bad); }
.stat.warn .stat-ic { background: var(--warn-soft); color: var(--warn); }
.stat.info .stat-ic { background: var(--info-soft); color: var(--info); }
.stat-num { font-size: 26px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 600; }

.chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; height: 170px; align-items: end; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; text-decoration: none !important; color: var(--muted); }
.bar-stack { flex: 1; width: 100%; max-width: 38px; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 8px; background: var(--bg-2); overflow: hidden; }
.bar { width: 100%; transition: height .5s cubic-bezier(.2,.8,.2,1); }
.bar.g { background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
.bar.r { background: var(--bad); }
.bar-num { font-size: 12px; font-weight: 700; color: var(--text); min-height: 18px; }
.bar-label { font-size: 12px; font-weight: 600; }
.bar-label.today { color: var(--accent); }
.bar-col:hover .bar-stack { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); }

/* feed / timeline */
.feed { list-style: none; margin: 0; padding: 0; }
.feed-item { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: start; padding: 11px 2px; border-bottom: 1px solid var(--line); animation: fadein .25s ease; }
.feed-item:last-child { border-bottom: 0; }
.feed-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--muted); box-shadow: 0 0 0 4px var(--bg-2); }
.feed-item.ok .feed-dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.feed-item.bad .feed-dot { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.feed-item.warn .feed-dot { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.feed-item.info .feed-dot { background: var(--info); box-shadow: 0 0 0 4px var(--info-soft); }
.feed-main { min-width: 0; }
.feed-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.feed-title a { color: var(--text); }
.add-card-link { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; padding: 2px 8px 2px 5px; border-radius: 999px; background: var(--accent-soft); }
.add-card-link .ic { width: 14px; height: 14px; }
.add-card-link:hover { text-decoration: none; filter: brightness(.97); }
.feed-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.feed-sub:empty { display: none; }
.feed-time { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; padding-top: 1px; }
.feed.compact .feed-item { padding: 8px 2px; }
.feed-card .feed { max-height: 640px; overflow-y: auto; }

/* ------------------------------------------------ toolbars, people */
.toolbar { display: flex; align-items: center; gap: 8px; }
.toolbar.sticky { position: sticky; top: calc(58px + env(safe-area-inset-top)); z-index: 10; padding: 8px 0; margin: -8px 0 4px; background: var(--bg); }
@media (min-width: 900px) { .toolbar.sticky { top: 66px; } }
.toolbar-2 { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar-2 .chips { min-width: 0; max-width: 100%; }
.search { position: relative; flex: 1; min-width: 0; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; pointer-events: none; }
.search input { padding-left: 38px; min-height: 46px; border-radius: 12px; }
.search.sm { flex: 0 1 220px; }
.search.sm input { min-height: 38px; }
.add-btn { min-height: 46px; border-radius: 12px; }
.sort-select { width: auto; min-height: 36px; padding: 6px 30px 6px 10px; font-size: 14px; border-radius: 10px; }
@media (max-width: 560px) { .add-btn span { display: none; } .add-btn { width: 46px; padding: 0; } }

.list-bar { display: flex; align-items: center; gap: 8px; margin: -2px 0 10px; flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 2px; }
.pager.bottom { justify-content: center; margin-top: 14px; }
.pg { width: 38px; height: 38px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; }
.pg:disabled { opacity: .35; cursor: default; background: transparent; }
.pg:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
.pg-label { padding: 0 10px; font-size: 14px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pg-label strong { color: var(--text); }
@media (max-width: 560px) { .pager.bottom .pg { width: 46px; height: 46px; } }
.plist { display: flex; flex-direction: column; gap: 8px; }
.plist-head { display: none; }
.prow {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name status" "name last";
  gap: 2px 10px; align-items: center; padding: 12px 14px; border-radius: var(--r); background: var(--panel);
  border: 1px solid var(--line); color: var(--text); text-decoration: none !important; box-shadow: var(--shadow); transition: border-color .15s, transform .08s;
}
.prow:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.prow:active { transform: scale(.995); }
.prow.skel { min-height: 66px; }
.p-reg { display: none; }
.p-name { grid-area: name; display: flex; align-items: center; gap: 12px; min-width: 0; }
.p-name-text { display: flex; flex-direction: column; min-width: 0; }
.p-name-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-card-m { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-card { display: none; }
.p-status { grid-area: status; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.p-reason { font-size: 12px; color: var(--muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-last { grid-area: last; font-size: 12px; text-align: right; }
.prow.present { grid-template-columns: 1fr 1fr; grid-template-areas: none; gap: 10px; }
.prow.present .p-name { grid-column: 1 / -1; }
.kv { display: flex; flex-direction: column; font-size: 14px; }
.kv small { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-family: var(--font); }

@media (min-width: 900px) {
  .plist { gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
  .plist-head { display: grid; grid-template-columns: 80px minmax(220px, 2fr) 1.2fr 1.4fr 1fr; gap: 12px; padding: 10px 16px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
  .prow { grid-template-columns: 80px minmax(220px, 2fr) 1.2fr 1.4fr 1fr; grid-template-areas: none; gap: 12px; border-radius: 0; border: 0; border-top: 1px solid var(--line); box-shadow: none; padding: 10px 16px; }
  .prow:hover { background: var(--panel-2); }
  .p-reg { display: block; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }
  .p-name { grid-area: auto; }
  .p-card-m { display: none; }
  .p-card { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
  .p-status { grid-area: auto; align-items: flex-start; text-align: left; }
  .p-reason { max-width: 260px; }
  .p-last { grid-area: auto; text-align: left; font-size: 14px; }
  .prow.present { grid-template-columns: minmax(220px, 2fr) 1fr 1fr 1fr 1.2fr; }
  .prow.present .p-name { grid-column: auto; }
}

/* ------------------------------------------------ person page */
.person-head { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.ph-top { display: flex; align-items: center; gap: 14px; }
.ph-text h2 { font-size: 22px; font-weight: 800; }
.ph-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.reg { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 560px) { .ph-actions .btn { flex: 1; } }
.status-note { border-radius: 12px; padding: 10px 12px; font-size: 14px; background: var(--bg-2); }
.status-note.bad { background: var(--bad-soft); }
.status-note.bad strong { color: var(--bad); }
.status-note.warn { background: var(--warn-soft); }
.status-note.warn strong { color: var(--warn); }

.person-form { display: flex; flex-direction: column; }
.person-form .section { margin-top: 0; margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: 1fr 1fr; } .grid .wide { grid-column: 1 / -1; } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(4, 1fr); } .grid .wide { grid-column: span 2; } }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row > input { flex: 1 1 200px; width: auto; }
.barcode { font-family: var(--mono); font-size: 14px; }
.barcode::placeholder { font-family: var(--font); font-size: 15px; }
.section.flash { animation: flash .9s ease; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
.scan-video { width: 100%; max-height: 55vh; border-radius: 12px; background: #000; margin-top: 10px; object-fit: cover; }
.cards { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.card-item { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.card-item .mono { font-size: 15px; font-weight: 600; }
.card-item.off .mono { text-decoration: line-through; color: var(--muted); }
.photo-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.id-photo { max-width: min(320px, 100%); max-height: 220px; border-radius: 12px; border: 1px solid var(--line); cursor: zoom-in; }
.id-photo-full { width: 100%; height: auto; border-radius: 12px; }
.photo-empty { width: 200px; height: 126px; border: 2px dashed var(--line); border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 13px; }
.photo-empty .ic { width: 30px; height: 30px; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); }
.danger-zone .card-head { margin-bottom: 4px; }
.danger-zone p { margin: 0 0 12px; }

.save-bar {
  position: sticky; bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom)); z-index: 15; display: none; align-items: center; gap: 8px;
  margin-top: 4px; padding: 10px 12px; border-radius: 16px; background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
}
.save-bar.show { display: flex; animation: fadein .2s ease; }
@media (min-width: 900px) { .save-bar { bottom: 16px; } }
@media (max-width: 480px) { .save-hint { display: none; } .save-bar .btn { flex: 1; } }

/* ------------------------------------------------ activity */
.activity { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.activity > *, .day { min-width: 0; }
.page-activity .toolbar.sticky { flex-wrap: wrap; }
.page-activity .toolbar input[type=date] { flex: 1 1 140px; }
@media (max-width: 560px) {
  .page-activity .toolbar-2 .search.sm { flex: 1 1 100%; order: 3; }
  .page-activity .toolbar-2 .btn { flex: 1; }
}
.cal { display: none; }
.cal.show { display: block; animation: fadein .2s ease; }
.cal-toggle { margin-left: auto; }
@media (min-width: 1000px) {
  .activity { grid-template-columns: 330px minmax(0, 1fr); align-items: start; }
  .cal { display: block; position: sticky; top: 84px; }
  .cal-toggle { display: none; }
}
.toolbar input[type=date] { width: auto; flex: 0 1 180px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dow { font-size: 11px; font-weight: 700; color: var(--muted); text-align: center; padding: 4px 0; }
.cal-day { position: relative; aspect-ratio: 1; min-width: 0; border: 0; border-radius: 10px; background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--text); overflow: hidden; padding: 0; }
.cal-day:hover { background: var(--bg-2); }
.cal-day .n { position: relative; z-index: 1; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-day .heat { position: absolute; inset: 3px; border-radius: 8px; background: var(--accent-soft); }
.cal-day .heat.has-r::after { content: ""; position: absolute; right: 4px; top: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--bad); }
.cal-day .cnt { position: absolute; z-index: 1; bottom: 3px; left: 0; right: 0; font-size: 9px; font-weight: 700; color: var(--accent); }
.cal-day.future { color: var(--muted); opacity: .6; }
.cal-day.today .n { color: var(--accent); }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day.sel { background: var(--accent); }
.cal-day.sel .n, .cal-day.sel .cnt { color: var(--on-accent); }
.cal-day.sel .heat { display: none; }
.cal-legend { font-size: 12px; color: var(--muted); margin: 10px 0 0; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.heat-sample { display: inline-block; width: 12px; height: 12px; border-radius: 4px; background: var(--accent-soft); }
.dot.r { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }
.day-title { font-size: 22px; font-weight: 800; margin: 8px 0 6px; }
.day-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.sum { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 5px 11px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.sum .ic { width: 16px; height: 16px; }
.sum.ok { color: var(--ok); } .sum.bad { color: var(--bad); }
.timeline .feed-item { padding: 12px 4px; }

/* ------------------------------------------------ more menu */
.menu-card { padding: 6px; }
.menu-card + .menu-card { margin-top: 12px; }
.menu-card .seg { margin: 6px 8px 8px; }
.menu-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px 0; }
.menu-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 13px 10px; border: 0; background: transparent; border-radius: 10px; font-size: 15px; font-weight: 600; color: var(--text); text-align: left; cursor: pointer; text-decoration: none !important; }
.menu-item:hover { background: var(--bg-2); }
.menu-item span { flex: 1; }
.menu-item .chev { color: var(--muted); width: 18px; height: 18px; }
.me.big { display: flex; align-items: center; gap: 12px; padding: 10px; }
.me.big .avatar { width: 46px; height: 46px; font-size: 18px; }

/* ------------------------------------------------ portal users */
.ulist { display: flex; flex-direction: column; gap: 8px; }
.urow { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "av main more" "av last more"; gap: 2px 12px; align-items: center; width: 100%;
  padding: 12px 12px 12px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); text-align: left; cursor: pointer; color: var(--text); font: inherit; }
.urow:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.urow.off { opacity: .65; }
.urow .avatar { grid-area: av; }
.u-main { grid-area: main; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.u-name { display: flex; align-items: baseline; gap: 6px; }
.u-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.u-last { grid-area: last; }
.u-more { grid-area: more; color: var(--muted); }
@media (min-width: 900px) {
  .urow { grid-template-columns: auto minmax(0, 1fr) 200px auto; grid-template-areas: "av main last more"; }
}
.sheet-badges { padding: 0 10px 8px; }
.menu-card.flat { padding: 0; margin: 0 -8px; }
.block-sub { display: block; font-weight: 500; margin-top: 1px; }
.menu-item small.block-sub { font-size: 12px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; margin-top: 2px; accent-color: var(--accent); flex: none; }
.warn-text { margin: -4px 0 0; font-size: 13px; color: var(--bad); background: var(--bad-soft); padding: 8px 10px; border-radius: 10px; }
.seg.wide { display: flex; }
.seg.wide .seg-btn { flex: 1; justify-content: center; padding: 9px 10px; font-size: 14px; }
.temp-pw { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); border: 1px dashed color-mix(in srgb, var(--accent) 50%, transparent); }
.temp-pw .mono { font-size: 20px; font-weight: 700; letter-spacing: .02em; user-select: all; word-break: break-all; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; color: var(--text); }

/* sign-in 2FA setup */
.qr-box { display: grid; place-items: center; padding: 14px; background: #fff; border-radius: 14px; border: 1px solid var(--line); }
.qr { width: 220px; height: 220px; image-rendering: pixelated; }
.manual-key summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); }
.manual-key .key { margin-top: 8px; padding: 10px; border-radius: 10px; background: var(--bg-2); font-size: 15px; word-spacing: .2em; user-select: all; }

/* ------------------------------------------------ modal sheet */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(9, 11, 17, 0); display: flex; align-items: flex-end; justify-content: center; transition: background .2s; }
.scrim.in { background: rgba(9, 11, 17, .5); }
.sheet {
  width: 100%; max-height: 92vh; overflow: auto; background: var(--panel); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  padding-bottom: env(safe-area-inset-bottom); transform: translateY(100%); transition: transform .24s cubic-bezier(.2,.8,.2,1);
}
.scrim.in .sheet { transform: none; }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px 4px 20px; }
.sheet-head h2 { font-size: 18px; flex: 1; }
.sheet-body { padding: 8px 20px 12px; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 20px 18px; }
@media (max-width: 560px) { .sheet-foot .btn { flex: 1; min-height: 48px; } }
@media (min-width: 640px) {
  .scrim { align-items: center; padding: 20px; }
  .sheet { width: min(520px, 100%); border-radius: 20px; transform: translateY(12px) scale(.98); opacity: 0; transition: transform .2s, opacity .2s; }
  .scrim.in .sheet { opacity: 1; }
  .sheet::before { display: none; }
  .sheet-head { padding-top: 16px; }
}

/* ------------------------------------------------ toasts */
.toasts { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(440px, calc(100% - 24px)); pointer-events: none; }
@media (min-width: 900px) { .toasts { bottom: 22px; left: auto; right: 22px; transform: none; align-items: flex-end; } }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 14px; background: #111827; color: #fff; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; max-width: 100%; }
.toast.in { opacity: 1; transform: none; }
.toast .ic { width: 18px; height: 18px; }
.toast.ok .ic { color: #34d399; }
.toast.bad .ic { color: #f87171; }

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