.popover {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 320px;
  max-width: 420px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-dropdown);
  z-index: 100;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  overflow-x: hidden;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--fg-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.addBtn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg-secondary);
  font-size: var(--font-2xs);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.addBtn:hover {
  background: var(--bg-highlight);
  color: var(--fg-primary);
}

.section {
  padding: 4px 0;
}

.sectionTitle {
  padding: 4px 12px;
  font-size: var(--font-2xs);
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ruleItem {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: default;
  transition: background 0.1s;
}

.ruleItem:hover {
  background: var(--bg-highlight);
}

.triggerBadge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: var(--radius-md);
  background: var(--bg-highlight);
  color: var(--fg-secondary);
  font-size: var(--font-2xs);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.ruleName {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--font-xs);
  color: var(--fg-primary);
}

.fireCount {
  font-size: var(--font-2xs);
  color: var(--fg-muted);
  flex-shrink: 0;
}

.statusDot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.statusActive {
  background: var(--success);
}

.statusPaused {
  background: var(--warning);
}

.statusExhausted {
  background: var(--fg-muted);
}

.statusStopped {
  background: var(--error);
}

.actionBtn {
  padding: 2px 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg-secondary);
  font-size: var(--font-2xs);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.actionBtn:hover {
  background: var(--bg-highlight);
  color: var(--fg-primary);
}

.deleteBtn {
  composes: actionBtn;
  color: var(--error);
}

.deleteBtn:hover {
  background: color-mix(in srgb, var(--error) 15%, transparent);
  color: var(--error);
}

.emptyState {
  padding: 16px 12px;
  text-align: center;
  color: var(--fg-muted);
  font-size: var(--font-xs);
}

.createForm {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.formRow {
  display: flex;
  align-items: center;
  gap: 6px;
}

.formInput {
  flex: 1;
  padding: 4px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg-primary);
  font-size: var(--font-xs);
  font-family: inherit;
  outline: none;
}

.formInput:focus {
  border-color: var(--accent);
}

.formSelect {
  padding: 4px 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg-primary);
  font-size: var(--font-xs);
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.formSelect:focus {
  border-color: var(--accent);
}

.formTextarea {
  width: 100%;
  min-height: 48px;
  padding: 4px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg-primary);
  font-size: var(--font-xs);
  font-family: inherit;
  resize: vertical;
  outline: none;
}

.formTextarea:focus {
  border-color: var(--accent);
}

.formActions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.submitBtn {
  padding: 4px 12px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-on-accent);
  font-size: var(--font-xs);
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.submitBtn:hover {
  opacity: 0.85;
}

.submitBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cancelBtn {
  padding: 4px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg-secondary);
  font-size: var(--font-xs);
  cursor: pointer;
  transition: background 0.15s;
}

.cancelBtn:hover {
  background: var(--bg-highlight);
}

.sessionPicker {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  margin: 4px 12px;
}

.sessionOption {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--fg-primary);
  font-size: var(--font-xs);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.1s;
}

.sessionOption:hover {
  background: var(--bg-highlight);
}

.unit {
  font-size: var(--font-2xs);
  color: var(--fg-muted);
  flex-shrink: 0;
}

.helpTip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-highlight);
  color: var(--fg-muted);
  font-size: 9px;
  font-weight: 600;
  cursor: help;
  flex-shrink: 0;
}
