:root {
  color-scheme: dark;
  --bg: #071019;
  --bg-soft: #0b1621;
  --panel: rgba(14, 29, 41, 0.88);
  --panel-solid: #0e1d29;
  --line: rgba(152, 183, 202, 0.15);
  --line-strong: rgba(152, 183, 202, 0.28);
  --text: #f1f6f8;
  --muted: #8ea2ae;
  --accent: #52d6c8;
  --accent-dark: #163d3c;
  --blue: #70a5ff;
  --critical: #ff626b;
  --critical-soft: rgba(255, 98, 107, 0.12);
  --alerta: #f0a13c;
  --alerta-soft: rgba(240, 161, 60, 0.12);
  --radius: 18px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(
      circle at 80% 0%,
      rgba(40, 108, 116, 0.12),
      transparent 32rem
    ),
    linear-gradient(145deg, #071019 0%, #09141e 48%, #071018 100%);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}
button,
select {
  cursor: pointer;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}
.ambient {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
  opacity: 0.15;
}
.ambient-one {
  width: 26rem;
  height: 26rem;
  background: #1c928d;
  top: -12rem;
  right: -8rem;
}
.ambient-two {
  width: 20rem;
  height: 20rem;
  background: #1c4e76;
  bottom: -10rem;
  left: 10%;
}
.muted {
  color: var(--muted);
  line-height: 1.55;
}
.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--accent);
  font-size: 0.69rem;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.login-shell {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(16rem, 1fr) minmax(22rem, 31rem);
  align-items: center;
  gap: 8vw;
  padding: 5vw 10vw;
  position: relative;
  z-index: 1;
}
.login-brand {
  justify-self: center;
  text-align: center;
  letter-spacing: 0.52em;
  font-size: 0.8rem;
  color: #cbe4e6;
}
.brand-mark {
  width: 2.35rem;
  height: 2.35rem;
  display: grid;
  place-items: center;
  border: 1px solid rgba(82, 214, 200, 0.7);
  border-radius: 12px;
  transform: rotate(45deg);
  box-shadow:
    inset 0 0 20px rgba(82, 214, 200, 0.1),
    0 0 24px rgba(82, 214, 200, 0.08);
}
.brand-mark span {
  width: 0.76rem;
  height: 0.76rem;
  border: 2px solid var(--accent);
  border-radius: 50%;
  position: relative;
}
.brand-mark span::after {
  content: "";
  position: absolute;
  width: 0.26rem;
  height: 0.26rem;
  background: var(--accent);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.brand-mark-large {
  width: 7rem;
  height: 7rem;
  margin: 0 auto 2.5rem;
  border-radius: 27px;
}
.brand-mark-large span {
  width: 2.2rem;
  height: 2.2rem;
}
.login-card {
  padding: 3rem;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(12, 27, 39, 0.82);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
}
.login-card h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.04em;
}
.login-card > .muted {
  margin: 0.65rem 0 2rem;
}
label {
  display: grid;
  gap: 0.48rem;
  color: #c7d4da;
  font-size: 0.78rem;
  font-weight: 650;
}
.login-card label {
  margin-top: 1.1rem;
}
input,
select {
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  color: var(--text);
  background: rgba(4, 13, 21, 0.72);
  transition:
    border-color 0.2s,
    background 0.2s;
}
input:hover,
select:hover {
  border-color: var(--line-strong);
}
input:focus,
select:focus {
  border-color: rgba(82, 214, 200, 0.7);
  background: #091721;
}
.form-error {
  min-height: 1.2rem;
  margin: 0.8rem 0;
  color: #ff9da3;
  font-size: 0.78rem;
}
.secure-note {
  margin: 1.2rem 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.7rem;
}
.secure-note span {
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
}

.button {
  min-height: 2.75rem;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  color: var(--text);
  font-weight: 720;
  font-size: 0.78rem;
  transition:
    transform 0.15s,
    background 0.2s,
    border-color 0.2s;
}
.button:hover {
  transform: translateY(-1px);
}
.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}
.button-primary {
  color: #041211;
  background: var(--accent);
  box-shadow: 0 8px 24px rgba(82, 214, 200, 0.14);
}
.button-primary:hover {
  background: #6ce1d5;
}
.button-ghost {
  border-color: var(--line);
  background: transparent;
  color: #b9c7cd;
}
.button-wide {
  width: 100%;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  position: relative;
  z-index: 1;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.8rem 1.25rem;
  border-right: 1px solid var(--line);
  background: rgba(6, 16, 24, 0.86);
  backdrop-filter: blur(20px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 0.65rem;
  color: var(--text);
  text-decoration: none;
}
.brand .brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 9px;
}
.brand strong {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
}
.brand small {
  display: block;
  margin-top: 0.16rem;
  color: var(--muted);
  font-size: 0.55rem;
  letter-spacing: 0.34em;
}
.nav {
  display: grid;
  gap: 0.45rem;
  margin-top: 3.5rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 2.75rem;
  border: 0;
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  color: #8ea3ae;
  background: transparent;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 680;
}
.nav-item:hover {
  color: #d9e4e8;
  background: rgba(255, 255, 255, 0.025);
}
.nav-item.active {
  color: var(--text);
  background: rgba(82, 214, 200, 0.09);
  box-shadow: inset 2px 0 var(--accent);
}
.nav-icon {
  width: 1.25rem;
  color: var(--accent);
  font-size: 1rem;
  text-align: center;
}
.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  margin-top: auto;
  padding: 1rem 0.65rem 0;
  border-top: 1px solid var(--line);
}
.sidebar-foot small,
.sidebar-foot strong {
  display: block;
}
.sidebar-foot small {
  color: var(--muted);
  font-size: 0.62rem;
}
.sidebar-foot strong {
  margin-top: 0.12rem;
  font-size: 0.72rem;
}
.status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #6d7c84;
  box-shadow: 0 0 0 4px rgba(109, 124, 132, 0.1);
}
.status-dot.online {
  background: var(--accent);
  box-shadow:
    0 0 0 4px rgba(82, 214, 200, 0.1),
    0 0 12px rgba(82, 214, 200, 0.5);
}
.status-dot.error {
  background: #e9ae62;
  box-shadow: 0 0 0 4px rgba(233, 174, 98, 0.1);
}

.workspace {
  min-width: 0;
}
.topbar {
  min-height: 6.7rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.4rem 2.2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 25, 0.36);
}
.topbar h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -0.035em;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.tenant-picker {
  gap: 0.25rem;
}
.tenant-picker span {
  color: var(--muted);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.tenant-picker select {
  min-width: 12rem;
  min-height: 2.75rem;
  padding: 0.45rem 0.75rem;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.75rem 0.4rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}
.user-chip > span {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--accent);
  background: var(--accent-dark);
  font-size: 0.68rem;
  font-weight: 800;
}
.user-chip strong,
.user-chip small {
  display: block;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-chip strong {
  font-size: 0.68rem;
}
.user-chip small {
  margin-top: 0.14rem;
  color: var(--muted);
  font-size: 0.58rem;
}
.icon-button {
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
}
.icon-button:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

main {
  padding: 1.8rem 2.2rem 3rem;
}
.tab-panel {
  display: none;
  animation: fade 0.22s ease;
}
.tab-panel.active {
  display: block;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.metric-card {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 0.9rem;
  min-height: 5.8rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}
.metric-icon {
  width: 2.3rem;
  height: 2.3rem;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--accent);
  background: rgba(82, 214, 200, 0.09);
}
.metric-card small,
.metric-card strong {
  display: block;
}
.metric-card small {
  color: var(--muted);
  font-size: 0.67rem;
}
.metric-card strong {
  margin-top: 0.12rem;
  font-size: 1.45rem;
  letter-spacing: -0.04em;
}
.metric-card em {
  justify-self: end;
  color: #718590;
  font-size: 0.62rem;
  font-style: normal;
}
.metric-critical .metric-icon {
  color: var(--critical);
  background: var(--critical-soft);
}
.metric-critical strong {
  color: var(--critical);
}
.live-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(19rem, 0.85fr);
  align-items: start;
  gap: 1rem;
  margin-bottom: 1rem;
}
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}
.panel-header {
  min-height: 4.7rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--line);
}
.panel-header h2 {
  margin: 0;
  font-size: 0.98rem;
  letter-spacing: -0.02em;
}
.panel-header select {
  min-height: 2.75rem;
  min-width: 9rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.7rem;
}
.camera-tools {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.frame-stage {
  position: relative;
  min-height: 27rem;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #03080d;
}
.frame-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.05),
    transparent 65%,
    rgba(0, 0, 0, 0.6)
  );
}
.frame-stage img {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  object-fit: contain;
}
#tracking-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.frame-empty {
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  color: var(--muted);
  text-align: center;
}
.frame-empty strong {
  color: #b9c8cf;
  font-size: 0.85rem;
}
.frame-empty span {
  font-size: 0.68rem;
}
.frame-glyph {
  width: 3.4rem;
  height: 3.4rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  color: var(--accent);
  position: relative;
}
.frame-glyph::before {
  content: "";
  width: 1.25rem;
  height: 0.86rem;
  border: 1.5px solid var(--accent);
  border-radius: 3px;
}
.frame-glyph::after {
  content: "";
  position: absolute;
  width: 0.35rem;
  height: 0.35rem;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
}
.frame-overlay {
  position: absolute;
  z-index: 3;
  left: 1rem;
  right: 1rem;
  bottom: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.66rem;
}
.frame-overlay span {
  padding: 0.38rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.52);
}
.frame-overlay time {
  color: #c9d5d9;
}
.live-pill,
.privacy-pill,
.result-count {
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  font-size: 0.61rem;
  font-weight: 750;
}
.live-pill {
  color: var(--accent);
  background: rgba(82, 214, 200, 0.08);
}
.live-pill i {
  display: inline-block;
  width: 0.35rem;
  height: 0.35rem;
  margin-right: 0.28rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 7px var(--accent);
}
.privacy-pill {
  color: var(--blue);
  background: rgba(112, 165, 255, 0.1);
}
.result-count {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.table-wrap {
  width: 100%;
  overflow: auto;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}
.table-wrap:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.event-panel table {
  min-width: 46rem;
}
.history-table table {
  min-width: 58rem;
}
.video-config-intro {
  margin: 0;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--line);
}
.video-header-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.video-config-table {
  min-width: 50rem;
}
.video-config-table td:first-child strong,
.video-config-table td:first-child small {
  display: block;
}
.video-config-table td:first-child small {
  margin-top: 0.2rem;
  color: var(--muted);
}
.video-config-table input[type="number"] {
  width: 7rem;
  min-height: 2.4rem;
}
.video-config-table input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}
.video-state {
  display: inline-flex;
  padding: 0.32rem 0.5rem;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.61rem;
  font-weight: 750;
}
.video-state.active {
  color: var(--accent);
  background: rgba(82, 214, 200, 0.1);
  box-shadow: inset 0 0 0 1px rgba(82, 214, 200, 0.16);
}
.credentials-panel {
  margin-top: 1rem;
}
.camera-create-panel {
  margin-top: 1rem;
  border-color: rgba(82, 214, 200, 0.2);
}
.camera-create-form {
  display: grid;
  grid-template-columns: 0.7fr 1.4fr 1.2fr auto;
  align-items: end;
  gap: 0.8rem;
  padding: 1.2rem;
}
.camera-create-form label {
  display: grid;
  gap: 0.38rem;
  color: var(--muted);
  font-size: 0.65rem;
}
.camera-create-form input,
.camera-create-form select {
  min-height: 2.6rem;
}
.video-credentials-form {
  display: grid;
  grid-template-columns:
    minmax(9rem, 0.8fr)
    minmax(8rem, 0.6fr)
    minmax(10rem, 1fr)
    0.8fr
    0.8fr
    auto;
  align-items: end;
  gap: 0.8rem;
  padding: 1.2rem;
}
.video-credentials-form label {
  display: grid;
  gap: 0.38rem;
  color: var(--muted);
  font-size: 0.65rem;
}
.video-credentials-form input,
.video-credentials-form select {
  min-height: 2.6rem;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  padding: 0.68rem 1rem;
  color: #718690;
  background: rgba(5, 14, 21, 0.3);
  font-size: 0.58rem;
  font-weight: 760;
  letter-spacing: 0.09em;
  text-align: left;
  text-transform: uppercase;
}
td {
  padding: 0.8rem 1rem;
  border-top: 1px solid rgba(152, 183, 202, 0.08);
  color: #c5d1d6;
  font-size: 0.68rem;
  vertical-align: middle;
}
tr:hover td {
  background: rgba(255, 255, 255, 0.015);
}
.occupancy-list {
  max-height: 32rem;
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
  overflow: auto;
}
.occupancy-zone {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(4, 13, 21, 0.38);
  overflow: hidden;
}
.occupancy-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.8rem;
  border-bottom: 1px solid rgba(152, 183, 202, 0.08);
}
.occupancy-title strong,
.occupancy-title small {
  display: block;
}
.occupancy-title strong {
  font-size: 0.74rem;
}
.occupancy-title small {
  margin-top: 0.16rem;
  color: var(--muted);
  font-size: 0.63rem;
}
.occupancy-total {
  flex: 0 0 auto;
  padding: 0.38rem 0.55rem;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(82, 214, 200, 0.09);
  font-size: 0.63rem;
  font-weight: 800;
}
.identity-list {
  display: grid;
  gap: 0.42rem;
  margin: 0;
  padding: 0.65rem;
  list-style: none;
}
.identity-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
}
.identity-avatar {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--blue);
  background: rgba(112, 165, 255, 0.1);
  font-size: 0.62rem;
  font-weight: 850;
}
.identity-item strong,
.identity-item time,
.identity-item small {
  display: block;
}
.identity-item strong {
  overflow: hidden;
  font-size: 0.69rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.identity-item time,
.identity-item small {
  margin-top: 0.14rem;
  color: var(--muted);
  font-size: 0.58rem;
}
.identity-anonymous {
  border: 1px dashed var(--line);
  background: transparent;
}
.identity-anonymous .identity-avatar {
  color: var(--muted);
  background: rgba(142, 162, 174, 0.08);
}
.identity-empty {
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.66rem;
  text-align: center;
}
.occupancy-state {
  padding: 0.5rem 0.8rem;
  border-top: 1px solid rgba(152, 183, 202, 0.08);
  color: var(--muted);
  font-size: 0.58rem;
}
.occupancy-state::before {
  content: "";
  width: 0.38rem;
  height: 0.38rem;
  display: inline-block;
  margin-right: 0.35rem;
  border-radius: 50%;
  background: #6d7c84;
}
.occupancy-state.online {
  color: var(--accent);
}
.occupancy-state.online::before {
  background: var(--accent);
  box-shadow: 0 0 7px rgba(82, 214, 200, 0.5);
}
.event-type {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.3rem 0.48rem;
  color: #c9d6db;
  font-size: 0.6rem;
}
tr.critical td {
  background: var(--critical-soft);
}
tr.critical .event-type {
  color: var(--critical);
  border-color: rgba(255, 98, 107, 0.32);
}
tr.alerta td {
  background: var(--alerta-soft);
}
tr.alerta .event-type {
  color: var(--alerta);
  border-color: rgba(240, 161, 60, 0.32);
}
.confidence {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.empty-row {
  padding: 2rem !important;
  color: var(--muted);
  text-align: center;
}
.text-button {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  border: 0;
  color: var(--accent);
  background: transparent;
  font-size: 0.68rem;
  font-weight: 720;
}
.event-panel .table-wrap {
  max-height: 18rem;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr 1.2fr 0.8fr auto auto;
  align-items: end;
  gap: 0.7rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--line);
}
.filters label {
  font-size: 0.62rem;
}
.filters input,
.filters select {
  min-width: 0;
  min-height: 2.75rem;
  font-size: 0.68rem;
}
.filters .button {
  min-height: 2.75rem;
}
.history-table {
  max-height: 34rem;
}

.people-grid {
  display: grid;
  grid-template-columns: minmax(20rem, 0.85fr) minmax(22rem, 1.15fr);
  gap: 1rem;
}
.enrollment-card > .muted {
  margin: 1rem 1.2rem 0;
  font-size: 0.72rem;
}
.guided-start > .muted,
.manual-alternative > .muted {
  margin: 1rem 1.2rem 0;
  font-size: 0.72rem;
}
.guided-wizard {
  display: grid;
  gap: 1rem;
  padding: 1.1rem 1.2rem 1.3rem;
}
.guided-progress {
  display: grid;
  gap: 0.6rem;
}
.guided-progress > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  font-size: 0.68rem;
}
.guided-progress strong {
  color: var(--accent);
  font-size: 0.62rem;
}
.guided-progress progress {
  width: 100%;
  height: 0.45rem;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  accent-color: var(--accent);
}
.guided-progress progress::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.06);
}
.guided-progress progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--accent);
}
.guided-preview {
  aspect-ratio: 4 / 3;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #03080d;
}
.guided-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.face-position-guide {
  position: absolute;
  border: 3px solid #52d6c8;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7), 0 0 14px rgba(82, 214, 200, 0.3);
  pointer-events: none;
  transition: left 120ms linear, top 120ms linear, width 120ms linear,
    height 120ms linear, border-color 120ms ease;
}
.face-position-guide[hidden] {
  display: none;
}
.face-position-guide[data-state="acercarse"] {
  border-color: #ffd166;
}
.face-position-guide[data-state="alejarse"] {
  border-color: #76b7ff;
}
.face-position-guide[data-state="distancia_correcta"] {
  border-color: #65e59a;
}
.face-position-guide span {
  position: absolute;
  top: -1.65rem;
  left: -3px;
  padding: 0.22rem 0.4rem;
  border-radius: 5px;
  color: #081013;
  background: #52d6c8;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}
.face-position-guide[data-state="acercarse"] span {
  background: #ffd166;
}
.face-position-guide[data-state="alejarse"] span {
  background: #76b7ff;
}
.face-position-guide[data-state="distancia_correcta"] span {
  background: #65e59a;
}
.guided-distance-guide {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  z-index: 2;
  max-width: calc(100% - 1.5rem);
  padding: 0.38rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: #d6e0e3;
  background: rgba(3, 8, 13, 0.84);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  transform: translateX(-50%);
  white-space: nowrap;
}
.guided-distance-guide[data-state="acercarse"] {
  color: #ffd166;
}
.guided-distance-guide[data-state="alejarse"] {
  color: #76b7ff;
}
.guided-distance-guide[data-state="distancia_correcta"] {
  color: #65e59a;
}
.preview-cadence {
  position: absolute;
  right: 0.7rem;
  bottom: 0.7rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  color: #c9d5d9;
  background: rgba(0, 0, 0, 0.62);
  font-size: 0.58rem;
  letter-spacing: 0.05em;
}
.pose-guide {
  padding: 0.9rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 12px 12px 0;
  background: rgba(82, 214, 200, 0.05);
}
.pose-guide span,
.pose-guide small {
  color: var(--muted);
  font-size: 0.62rem;
}
.pose-guide small {
  display: block;
  margin-top: 0.25rem;
}
#guided-size-label {
  color: var(--accent);
  font-weight: 700;
}
.pose-guide h3 {
  margin: 0.25rem 0;
  font-size: 0.9rem;
}
.pose-guide p {
  margin: 0 0 0.35rem;
  color: #c5d1d6;
  font-size: 0.72rem;
  line-height: 1.5;
}
.guided-thumbnails {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
}
.guided-thumbnail {
  min-width: 0;
  margin: 0;
}
.guided-thumbnail img {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  border: 1px solid rgba(82, 214, 200, 0.34);
  border-radius: 9px;
  object-fit: cover;
}
.guided-thumbnail figcaption {
  margin-top: 0.3rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.55rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.guided-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.guided-actions .text-button {
  grid-column: 1 / -1;
  justify-content: center;
}
.manual-alternative {
  margin: 0 1.2rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(4, 13, 21, 0.28);
}
.manual-alternative summary {
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 720;
  cursor: pointer;
}
.manual-alternative[open] summary {
  border-bottom: 1px solid var(--line);
}
.manual-alternative .enrollment-form {
  padding-bottom: 1rem;
}
.enrollment-form {
  display: grid;
  gap: 1rem;
  padding: 1.1rem 1.2rem 1.3rem;
}
.file-drop {
  min-height: 8.5rem;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.32rem;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: #c9d6db;
  background: rgba(4, 13, 21, 0.36);
  text-align: center;
  cursor: pointer;
}
.file-drop:hover {
  border-color: var(--accent);
  background: rgba(82, 214, 200, 0.025);
}
.file-drop input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.file-drop small {
  color: var(--muted);
  font-size: 0.62rem;
}
.file-icon {
  color: var(--accent);
  font-size: 1.45rem;
}
.pose-fields {
  display: grid;
  gap: 0.5rem;
}
.pose-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1fr;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.pose-row span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.64rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pose-row input {
  min-height: 2.2rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.67rem;
}
fieldset {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
}
legend {
  padding: 0 0.4rem;
  color: var(--muted);
  font-size: 0.65rem;
}
.zone-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.zone-option {
  display: flex;
  grid: none;
  align-items: center;
  gap: 0.42rem;
  min-height: 2.75rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.64rem;
  cursor: pointer;
}
.zone-option input {
  width: 0.85rem;
  min-height: auto;
  accent-color: var(--accent);
}
.form-status {
  min-height: 1.1rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
}
.form-status.success {
  color: var(--accent);
}
.form-status.error {
  color: #ff9da3;
}
.people-list {
  max-height: 42rem;
  overflow: auto;
}
.person-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid rgba(152, 183, 202, 0.08);
}
.person-avatar {
  width: 2.2rem;
  height: 2.2rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--blue);
  background: rgba(112, 165, 255, 0.09);
  font-weight: 800;
  font-size: 0.65rem;
}
.person-info {
  min-width: 0;
  flex: 1;
}
.person-info strong,
.person-info small {
  display: block;
}
.person-info strong {
  overflow: hidden;
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.person-info small {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.57rem;
  overflow-wrap: anywhere;
}
.delete-button {
  min-height: 2.75rem;
  border: 0;
  padding: 0.45rem;
  color: #8fa1aa;
  background: transparent;
  font-size: 0.64rem;
}
.delete-button:hover {
  color: var(--critical);
}
.empty-card {
  padding: 3rem 1rem;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 1.5rem;
  bottom: 1.5rem;
  max-width: 24rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--text);
  background: #112531;
  box-shadow: var(--shadow);
  font-size: 0.72rem;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 0.22s ease;
}
.toast.show {
  opacity: 1;
  transform: none;
}
.toast.error {
  border-color: rgba(255, 98, 107, 0.35);
  background: #2b171d;
}

@media (max-width: 1100px) {
  .video-credentials-form,
  .camera-create-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .app-shell {
    grid-template-columns: 5rem minmax(0, 1fr);
  }
  .sidebar {
    padding-inline: 0.65rem;
  }
  .brand {
    justify-content: center;
    padding: 0;
  }
  .brand > div:last-child,
  .nav-item:not(.active) .nav-icon + *,
  .nav-item {
    font-size: 0;
  }
  .nav-item {
    justify-content: center;
  }
  .nav-icon {
    font-size: 1rem;
  }
  .sidebar-foot div {
    width: 1px;
    height: 1px;
    position: absolute;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .sidebar-foot {
    justify-content: center;
  }
  .filters {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 820px) {
  .video-credentials-form,
  .camera-create-form {
    grid-template-columns: 1fr;
  }
  .login-shell {
    grid-template-columns: 1fr;
    padding: 1.2rem;
  }
  .login-brand {
    display: none;
  }
  .login-card {
    width: min(100%, 30rem);
    justify-self: center;
    padding: 2rem;
  }
  .app-shell {
    display: block;
  }
  .sidebar {
    position: fixed;
    z-index: 10;
    top: auto;
    bottom: 0;
    width: 100%;
    height: calc(4.7rem + env(safe-area-inset-bottom));
    flex-direction: row;
    align-items: center;
    padding: 0.4rem 0.7rem env(safe-area-inset-bottom);
    border: 0;
    border-top: 1px solid var(--line);
  }
  .sidebar .brand {
    display: none;
  }
  .nav {
    min-width: 0;
    flex: 1;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.25rem;
    margin: 0;
  }
  .nav-item {
    min-height: 3.35rem;
    flex-direction: column;
    justify-content: center;
    gap: 0.18rem;
    padding: 0.45rem 0.3rem;
    font-size: 0.75rem;
    line-height: 1.1;
    text-align: center;
  }
  .nav-item.active {
    box-shadow: inset 0 2px var(--accent);
  }
  .nav-item .nav-icon {
    font-size: 1rem;
  }
  .sidebar-foot {
    width: 2.5rem;
    flex: 0 0 2.5rem;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: 0;
  }
  .workspace {
    padding-bottom: calc(4.7rem + env(safe-area-inset-bottom));
  }
  .topbar {
    min-height: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0.9rem;
    padding: 1.1rem;
  }
  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }
  .tenant-picker {
    grid-column: 1 / -1;
  }
  .tenant-picker select {
    width: 100%;
    min-width: 0;
  }
  .user-chip {
    min-width: 0;
  }
  .user-chip div {
    min-width: 0;
  }
  .user-chip strong,
  .user-chip small {
    max-width: min(15rem, 52vw);
  }
  main {
    padding: 1rem;
  }
  .metrics,
  .live-grid,
  .people-grid {
    grid-template-columns: 1fr;
  }
  .metric-card {
    min-height: 4.7rem;
  }
  .frame-stage {
    min-height: 0;
    aspect-ratio: 4 / 3;
  }
  .filters {
    grid-template-columns: 1fr 1fr;
  }
  .occupancy-list {
    max-height: none;
  }
}

@media (max-width: 520px) {
  .login-shell {
    align-items: center;
    padding:
      max(1rem, env(safe-area-inset-top))
      max(1rem, env(safe-area-inset-right))
      max(1rem, env(safe-area-inset-bottom))
      max(1rem, env(safe-area-inset-left));
  }
  .login-card {
    padding: 1.5rem;
    border-radius: 20px;
  }
  .login-card h1 {
    font-size: clamp(1.7rem, 8vw, 2rem);
  }
  .topbar h1 {
    font-size: 1.15rem;
  }
  .metrics {
    grid-template-columns: 1fr;
  }
  .metric-card {
    grid-template-columns: auto auto 1fr;
  }
  .metric-card em {
    display: block;
  }
  .panel-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .video-header-actions {
    width: 100%;
    justify-content: space-between;
  }
  .camera-panel .panel-header select {
    width: 100%;
  }
  .camera-tools {
    width: 100%;
    flex-wrap: wrap;
  }
  .camera-tools select {
    flex: 1 1 11rem;
  }
  .frame-overlay {
    align-items: flex-end;
    gap: 0.5rem;
  }
  .frame-overlay time {
    max-width: 55%;
    text-align: right;
  }
  .filters {
    grid-template-columns: 1fr;
  }
  .pose-row {
    grid-template-columns: 1fr;
  }
  .guided-progress > div {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.25rem;
  }
  .guided-actions {
    grid-template-columns: 1fr;
  }
  .guided-actions .text-button {
    grid-column: auto;
  }
  .guided-thumbnails {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  th {
    font-size: 0.65rem;
  }
  td {
    font-size: 0.75rem;
  }
  .toast {
    right: 1rem;
    bottom: calc(5.5rem + env(safe-area-inset-bottom));
    left: 1rem;
    max-width: none;
  }
}

@media (max-width: 380px) {
  .topbar,
  main {
    padding-inline: 0.8rem;
  }
  .panel-header,
  .enrollment-form {
    padding-inline: 1rem;
  }
  .metric-card {
    padding-inline: 1rem;
  }
  .user-chip strong,
  .user-chip small {
    max-width: 12rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
